zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 2f9cae345a309bfc28b0cc09bc57247fe0f07a9a (tree)
parent f097b4c3daff18d5dce1178831f294601f023b7b
Author: Matthew Lugg <mlugg@mlugg.co.uk>
Date:   Wed, 20 May 2026 17:08:42 +0100

Elf2: handle STB_GNU_UNIQUE in input objects

Diffstat:
Msrc/link/Elf2.zig | 20++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/link/Elf2.zig b/src/link/Elf2.zig @@ -3264,20 +3264,24 @@ fn loadObject( }; if (input_sym.shndx == std.elf.SHN_UNDEF) switch (input_sym.info.bind) { - _ => |bind| return diags.failParse( + else => |bind| return diags.failParse( path, "symbol '{s}' has unsupported binding (0x{x})", .{ name, bind }, ), .LOCAL => continue, - .GLOBAL, .WEAK => |bind| { + .GLOBAL, .WEAK, .GNU_UNIQUE => |bind| { si.* = elf.addGlobalSymbolAssumeCapacity(.{ .node = .none, .name = try .string(elf, name), .value = input_sym.value, .size = input_sym.size, .type = sym_type, - .bind = if (bind == .WEAK) .weak else .strong, + .bind = switch (bind) { + .WEAK, .GNU_UNIQUE => .weak, + .GLOBAL => .strong, + else => unreachable, + }, .visibility = input_sym.other.visibility, .shndx = .UNDEF, }) catch |err| switch (err) { @@ -3290,7 +3294,7 @@ fn loadObject( const input_section_node = (sections[input_sym.shndx].isi orelse continue).node(elf); switch (input_sym.info.bind) { - _ => |bind| return diags.failParse( + else => |bind| return diags.failParse( path, "symbol '{s}' has unsupported binding (0x{x})", .{ name, bind }, @@ -3306,14 +3310,18 @@ fn loadObject( }); si.* = .local(lsi); }, - .GLOBAL, .WEAK => |bind| { + .GLOBAL, .WEAK, .GNU_UNIQUE => |bind| { si.* = elf.addGlobalSymbolAssumeCapacity(.{ .node = input_section_node, .name = try .string(elf, name), .value = input_sym.value, .size = input_sym.size, .type = sym_type, - .bind = if (bind == .WEAK) .weak else .strong, + .bind = switch (bind) { + .WEAK, .GNU_UNIQUE => .weak, + .GLOBAL => .strong, + else => unreachable, + }, .visibility = input_sym.other.visibility, .shndx = elf.getNodeShndx(input_section_node), }) catch |err| switch (err) {