authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-05-20 17:08:42+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-05-26 06:30:28+01:00
log2f9cae345a309bfc28b0cc09bc57247fe0f07a9a
treed63b4efbebe5b2507b415320990cf60ec70eb0ba
parentf097b4c3daff18d5dce1178831f294601f023b7b
signaturelock-open Commit is signed but in an unrecognized format.

Elf2: handle STB_GNU_UNIQUE in input objects


1 files changed, 14 insertions(+), 6 deletions(-)

src/link/Elf2.zig+14-6
......@@ -3264,20 +3264,24 @@ fn loadObject(
32643264 };
32653265
32663266 if (input_sym.shndx == std.elf.SHN_UNDEF) switch (input_sym.info.bind) {
3267 _ => |bind| return diags.failParse(
3267 else => |bind| return diags.failParse(
32683268 path,
32693269 "symbol '{s}' has unsupported binding (0x{x})",
32703270 .{ name, bind },
32713271 ),
32723272 .LOCAL => continue,
3273 .GLOBAL, .WEAK => |bind| {
3273 .GLOBAL, .WEAK, .GNU_UNIQUE => |bind| {
32743274 si.* = elf.addGlobalSymbolAssumeCapacity(.{
32753275 .node = .none,
32763276 .name = try .string(elf, name),
32773277 .value = input_sym.value,
32783278 .size = input_sym.size,
32793279 .type = sym_type,
3280 .bind = if (bind == .WEAK) .weak else .strong,
3280 .bind = switch (bind) {
3281 .WEAK, .GNU_UNIQUE => .weak,
3282 .GLOBAL => .strong,
3283 else => unreachable,
3284 },
32813285 .visibility = input_sym.other.visibility,
32823286 .shndx = .UNDEF,
32833287 }) catch |err| switch (err) {
......@@ -3290,7 +3294,7 @@ fn loadObject(
32903294 const input_section_node = (sections[input_sym.shndx].isi orelse continue).node(elf);
32913295
32923296 switch (input_sym.info.bind) {
3293 _ => |bind| return diags.failParse(
3297 else => |bind| return diags.failParse(
32943298 path,
32953299 "symbol '{s}' has unsupported binding (0x{x})",
32963300 .{ name, bind },
......@@ -3306,14 +3310,18 @@ fn loadObject(
33063310 });
33073311 si.* = .local(lsi);
33083312 },
3309 .GLOBAL, .WEAK => |bind| {
3313 .GLOBAL, .WEAK, .GNU_UNIQUE => |bind| {
33103314 si.* = elf.addGlobalSymbolAssumeCapacity(.{
33113315 .node = input_section_node,
33123316 .name = try .string(elf, name),
33133317 .value = input_sym.value,
33143318 .size = input_sym.size,
33153319 .type = sym_type,
3316 .bind = if (bind == .WEAK) .weak else .strong,
3320 .bind = switch (bind) {
3321 .WEAK, .GNU_UNIQUE => .weak,
3322 .GLOBAL => .strong,
3323 else => unreachable,
3324 },
33173325 .visibility = input_sym.other.visibility,
33183326 .shndx = elf.getNodeShndx(input_section_node),
33193327 }) catch |err| switch (err) {