From 49637f537269ed98efb95a82e63ef73f6a9606a9 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 12 Oct 2024 10:42:29 -0700 Subject: [PATCH] objcopy: check both global and local when remapping --- lib/compiler/objcopy.zig | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/compiler/objcopy.zig b/lib/compiler/objcopy.zig index a46dcab9c8..bf031bb391 100644 --- a/lib/compiler/objcopy.zig +++ b/lib/compiler/objcopy.zig @@ -1179,13 +1179,10 @@ fn ElfFile(comptime is_64: bool) type { @memcpy(data, src_data); const defs = @as([*]elf.Verdef, @ptrCast(data))[0 .. @as(usize, @intCast(src.sh_size)) / @sizeOf(elf.Verdef)]; - for (defs) |*def| { - // 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); - } + for (defs) |*def| switch (def.ndx) { + .LOCAL, .GLOBAL => {}, + else => def.ndx = @enumFromInt(sections_update[src.sh_info].remap_idx), + }; break :dst_data data; },