authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-09-04 00:52:11+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-09-04 01:16:27+02:00
log210b764c03b736a6fe025b5fac030eec0350f0df
treef514d611bd432431fd1f06f84c33f62b061df33a
parenta82f446d91c9e764719d34188de5d794ee24dda8
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

link.Elf: truncate st_other to u3 before converting to std.elf.STV

See 6b6e336e07308fd23f3061b5be11407956b2a460 for context, but note that in gABI 4.3, 3 bits are reserved for the visibility, up from the previous 2.

3 files changed, 5 insertions(+), 5 deletions(-)

src/link/Elf/Object.zig+2-2
......@@ -634,7 +634,7 @@ pub fn claimUnresolved(self: *Object, elf_file: *Elf) void {
634634
635635 const is_import = blk: {
636636 if (!elf_file.isEffectivelyDynLib()) break :blk false;
637 const vis = @as(elf.STV, @enumFromInt(esym.st_other));
637 const vis: elf.STV = @enumFromInt(@as(u3, @truncate(esym.st_other)));
638638 if (vis == .HIDDEN) break :blk false;
639639 break :blk true;
640640 };
......@@ -707,7 +707,7 @@ pub fn markImportsExports(self: *Object, elf_file: *Elf) void {
707707 const file = sym.file(elf_file).?;
708708 // https://github.com/ziglang/zig/issues/21678
709709 if (@as(u16, @bitCast(sym.version_index)) == @as(u16, @bitCast(elf.Versym.LOCAL))) continue;
710 const vis: elf.STV = @enumFromInt(sym.elfSym(elf_file).st_other);
710 const vis: elf.STV = @enumFromInt(@as(u3, @truncate(sym.elfSym(elf_file).st_other)));
711711 if (vis == .HIDDEN) continue;
712712 if (file == .shared_object and !sym.isAbs(elf_file)) {
713713 sym.flags.import = true;
src/link/Elf/SharedObject.zig+1-1
......@@ -357,7 +357,7 @@ pub fn markImportExports(self: *SharedObject, elf_file: *Elf) void {
357357 const ref = self.resolveSymbol(@intCast(i), elf_file);
358358 const ref_sym = elf_file.symbol(ref) orelse continue;
359359 const ref_file = ref_sym.file(elf_file).?;
360 const vis = @as(elf.STV, @enumFromInt(ref_sym.elfSym(elf_file).st_other));
360 const vis: elf.STV = @enumFromInt(@as(u3, @truncate(ref_sym.elfSym(elf_file).st_other)));
361361 if (ref_file != .shared_object and vis != .HIDDEN) ref_sym.flags.@"export" = true;
362362 }
363363}
src/link/Elf/ZigObject.zig+2-2
......@@ -617,7 +617,7 @@ pub fn claimUnresolved(self: *ZigObject, elf_file: *Elf) void {
617617
618618 const is_import = blk: {
619619 if (!elf_file.isEffectivelyDynLib()) break :blk false;
620 const vis = @as(elf.STV, @enumFromInt(esym.st_other));
620 const vis: elf.STV = @enumFromInt(@as(u3, @truncate(esym.st_other)));
621621 if (vis == .HIDDEN) break :blk false;
622622 break :blk true;
623623 };
......@@ -695,7 +695,7 @@ pub fn markImportsExports(self: *ZigObject, elf_file: *Elf) void {
695695 const file = sym.file(elf_file).?;
696696 // https://github.com/ziglang/zig/issues/21678
697697 if (@as(u16, @bitCast(sym.version_index)) == @as(u16, @bitCast(elf.Versym.LOCAL))) continue;
698 const vis: elf.STV = @enumFromInt(sym.elfSym(elf_file).st_other);
698 const vis: elf.STV = @enumFromInt(@as(u3, @truncate(sym.elfSym(elf_file).st_other)));
699699 if (vis == .HIDDEN) continue;
700700 if (file == .shared_object and !sym.isAbs(elf_file)) {
701701 sym.flags.import = true;