mirror of
https://github.com/ziglang/zig.git
synced 2024-12-04 02:48:50 +00:00
objcopy: update for std.elf type safety
the new types make this code seem a bit strange
This commit is contained in:
parent
1ba3fc90be
commit
9b0a3942ef
@ -832,7 +832,6 @@ fn ElfFile(comptime is_64: bool) type {
|
||||
const Elf_Shdr = if (is_64) elf.Elf64_Shdr else elf.Elf32_Shdr;
|
||||
const Elf_Chdr = if (is_64) elf.Elf64_Chdr else elf.Elf32_Chdr;
|
||||
const Elf_Sym = if (is_64) elf.Elf64_Sym else elf.Elf32_Sym;
|
||||
const Elf_Verdef = if (is_64) elf.Elf64_Verdef else elf.Elf32_Verdef;
|
||||
const Elf_OffSize = if (is_64) elf.Elf64_Off else elf.Elf32_Off;
|
||||
|
||||
return struct {
|
||||
@ -1179,10 +1178,13 @@ fn ElfFile(comptime is_64: bool) type {
|
||||
const data = try allocator.alignedAlloc(u8, section_memory_align, src_data.len);
|
||||
@memcpy(data, src_data);
|
||||
|
||||
const defs = @as([*]Elf_Verdef, @ptrCast(data))[0 .. @as(usize, @intCast(src.sh_size)) / @sizeOf(Elf_Verdef)];
|
||||
const defs = @as([*]elf.Verdef, @ptrCast(data))[0 .. @as(usize, @intCast(src.sh_size)) / @sizeOf(elf.Verdef)];
|
||||
for (defs) |*def| {
|
||||
if (def.vd_ndx != elf.SHN_UNDEF)
|
||||
def.vd_ndx = sections_update[src.sh_info].remap_idx;
|
||||
// Original author of this next line had elf.SHN_UNDEF
|
||||
// here which does not make sense given that this field
|
||||
// is elf.VER_NDX
|
||||
if (def.ndx != .LOCAL)
|
||||
def.ndx = @enumFromInt(sections_update[src.sh_info].remap_idx);
|
||||
}
|
||||
|
||||
break :dst_data data;
|
||||
|
Loading…
Reference in New Issue
Block a user