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 {...@@ -634,7 +634,7 @@ pub fn claimUnresolved(self: *Object, elf_file: *Elf) void {
634634
635 const is_import = blk: {635 const is_import = blk: {
636 if (!elf_file.isEffectivelyDynLib()) break :blk false;636 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)));
638 if (vis == .HIDDEN) break :blk false;638 if (vis == .HIDDEN) break :blk false;
639 break :blk true;639 break :blk true;
640 };640 };
...@@ -707,7 +707,7 @@ pub fn markImportsExports(self: *Object, elf_file: *Elf) void {...@@ -707,7 +707,7 @@ pub fn markImportsExports(self: *Object, elf_file: *Elf) void {
707 const file = sym.file(elf_file).?;707 const file = sym.file(elf_file).?;
708 // https://github.com/ziglang/zig/issues/21678708 // https://github.com/ziglang/zig/issues/21678
709 if (@as(u16, @bitCast(sym.version_index)) == @as(u16, @bitCast(elf.Versym.LOCAL))) continue;709 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)));
711 if (vis == .HIDDEN) continue;711 if (vis == .HIDDEN) continue;
712 if (file == .shared_object and !sym.isAbs(elf_file)) {712 if (file == .shared_object and !sym.isAbs(elf_file)) {
713 sym.flags.import = true;713 sym.flags.import = true;
src/link/Elf/SharedObject.zig+1-1
...@@ -357,7 +357,7 @@ pub fn markImportExports(self: *SharedObject, elf_file: *Elf) void {...@@ -357,7 +357,7 @@ pub fn markImportExports(self: *SharedObject, elf_file: *Elf) void {
357 const ref = self.resolveSymbol(@intCast(i), elf_file);357 const ref = self.resolveSymbol(@intCast(i), elf_file);
358 const ref_sym = elf_file.symbol(ref) orelse continue;358 const ref_sym = elf_file.symbol(ref) orelse continue;
359 const ref_file = ref_sym.file(elf_file).?;359 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)));
361 if (ref_file != .shared_object and vis != .HIDDEN) ref_sym.flags.@"export" = true;361 if (ref_file != .shared_object and vis != .HIDDEN) ref_sym.flags.@"export" = true;
362 }362 }
363}363}
src/link/Elf/ZigObject.zig+2-2
...@@ -617,7 +617,7 @@ pub fn claimUnresolved(self: *ZigObject, elf_file: *Elf) void {...@@ -617,7 +617,7 @@ pub fn claimUnresolved(self: *ZigObject, elf_file: *Elf) void {
617617
618 const is_import = blk: {618 const is_import = blk: {
619 if (!elf_file.isEffectivelyDynLib()) break :blk false;619 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)));
621 if (vis == .HIDDEN) break :blk false;621 if (vis == .HIDDEN) break :blk false;
622 break :blk true;622 break :blk true;
623 };623 };
...@@ -695,7 +695,7 @@ pub fn markImportsExports(self: *ZigObject, elf_file: *Elf) void {...@@ -695,7 +695,7 @@ pub fn markImportsExports(self: *ZigObject, elf_file: *Elf) void {
695 const file = sym.file(elf_file).?;695 const file = sym.file(elf_file).?;
696 // https://github.com/ziglang/zig/issues/21678696 // https://github.com/ziglang/zig/issues/21678
697 if (@as(u16, @bitCast(sym.version_index)) == @as(u16, @bitCast(elf.Versym.LOCAL))) continue;697 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)));
699 if (vis == .HIDDEN) continue;699 if (vis == .HIDDEN) continue;
700 if (file == .shared_object and !sym.isAbs(elf_file)) {700 if (file == .shared_object and !sym.isAbs(elf_file)) {
701 sym.flags.import = true;701 sym.flags.import = true;