authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-09-04 10:58:28+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-09-04 10:58:28+02:00
logd94e061ade545f3fbdd4ab1a18f860b05050ebf6
treed4524d99ab3748c71a826b09c26276bd7f699b45
parent9649ff37ef15aae06d4020ce3b7210fa2aaf2a25
parent210b764c03b736a6fe025b5fac030eec0350f0df
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #25137 from alexrp/elf-gabi-4.3

ELF updates for gABI 4.3

6 files changed, 34 insertions(+), 20 deletions(-)

lib/std/Build/Step/CheckObject.zig+1-1
...@@ -2226,7 +2226,7 @@ const ElfDumper = struct {...@@ -2226,7 +2226,7 @@ const ElfDumper = struct {
2226 try writer.print(" {s}", .{sym_bind});2226 try writer.print(" {s}", .{sym_bind});
2227 }2227 }
22282228
2229 const sym_vis = @as(elf.STV, @enumFromInt(@as(u2, @truncate(sym.st_other))));2229 const sym_vis = @as(elf.STV, @enumFromInt(@as(u3, @truncate(sym.st_other))));
2230 try writer.print(" {s}", .{@tagName(sym_vis)});2230 try writer.print(" {s}", .{@tagName(sym_vis)});
22312231
2232 const sym_name = switch (sym.st_type()) {2232 const sym_name = switch (sym.st_type()) {
lib/std/elf.zig+27-13
...@@ -1122,17 +1122,17 @@ pub const OSABI = enum(u8) {...@@ -1122,17 +1122,17 @@ pub const OSABI = enum(u8) {
1122 CLOUDABI = 17,1122 CLOUDABI = 17,
1123 /// Stratus Technologies OpenVOS1123 /// Stratus Technologies OpenVOS
1124 OPENVOS = 18,1124 OPENVOS = 18,
1125 /// NVIDIA CUDA architecture1125 /// NVIDIA CUDA architecture (not gABI assigned)
1126 CUDA = 51,1126 CUDA = 51,
1127 /// AMD HSA Runtime1127 /// AMD HSA Runtime (not gABI assigned)
1128 AMDGPU_HSA = 64,1128 AMDGPU_HSA = 64,
1129 /// AMD PAL Runtime1129 /// AMD PAL Runtime (not gABI assigned)
1130 AMDGPU_PAL = 65,1130 AMDGPU_PAL = 65,
1131 /// AMD Mesa3D Runtime1131 /// AMD Mesa3D Runtime (not gABI assigned)
1132 AMDGPU_MESA3D = 66,1132 AMDGPU_MESA3D = 66,
1133 /// ARM1133 /// ARM (not gABI assigned)
1134 ARM = 97,1134 ARM = 97,
1135 /// Standalone (embedded) application1135 /// Standalone (embedded) application (not gABI assigned)
1136 STANDALONE = 255,1136 STANDALONE = 255,
11371137
1138 _,1138 _,
...@@ -1165,11 +1165,11 @@ pub const EM = enum(u16) {...@@ -1165,11 +1165,11 @@ pub const EM = enum(u16) {
1165 S370 = 9,1165 S370 = 9,
1166 /// MIPS R3000 (and R4000) little-endian, Oct 4 1993 Draft (deprecated)1166 /// MIPS R3000 (and R4000) little-endian, Oct 4 1993 Draft (deprecated)
1167 MIPS_RS3_LE = 10,1167 MIPS_RS3_LE = 10,
1168 /// Old version of Sparc v9, from before the ABI (deprecated)1168 /// Old version of Sparc v9, from before the ABI (not gABI assigned)
1169 OLD_SPARCV9 = 11,1169 OLD_SPARCV9 = 11,
1170 /// HPPA1170 /// HPPA
1171 PARISC = 15,1171 PARISC = 15,
1172 /// Fujitsu VPP500 (also old version of PowerPC; deprecated)1172 /// Fujitsu VPP500 (also old version of PowerPC, which was not gABI assigned)
1173 VPP500 = 17,1173 VPP500 = 17,
1174 /// Sun's "v8plus"1174 /// Sun's "v8plus"
1175 SPARC32PLUS = 18,1175 SPARC32PLUS = 18,
...@@ -1189,7 +1189,7 @@ pub const EM = enum(u16) {...@@ -1189,7 +1189,7 @@ pub const EM = enum(u16) {
1189 FR20 = 37,1189 FR20 = 37,
1190 /// TRW RH321190 /// TRW RH32
1191 RH32 = 38,1191 RH32 = 38,
1192 /// Motorola M*Core, aka RCE (also Fujitsu MMA)1192 /// Motorola M*Core, aka RCE (also old Fujitsu MMA, which was not gABI assigned)
1193 MCORE = 39,1193 MCORE = 39,
1194 /// ARM1194 /// ARM
1195 ARM = 40,1195 ARM = 40,
...@@ -1301,7 +1301,7 @@ pub const EM = enum(u16) {...@@ -1301,7 +1301,7 @@ pub const EM = enum(u16) {
1301 ARC_COMPACT = 93,1301 ARC_COMPACT = 93,
1302 /// Tensilica Xtensa Architecture1302 /// Tensilica Xtensa Architecture
1303 XTENSA = 94,1303 XTENSA = 94,
1304 /// Alphamosaic VideoCore processor (also old Sunplus S+core7 backend magic number)1304 /// Alphamosaic VideoCore processor (also old Sunplus S+core7 backend magic number, which was not gABI assigned)
1305 VIDEOCORE = 95,1305 VIDEOCORE = 95,
1306 /// Thompson Multimedia General Purpose Processor1306 /// Thompson Multimedia General Purpose Processor
1307 TMM_GPP = 96,1307 TMM_GPP = 96,
...@@ -1309,7 +1309,7 @@ pub const EM = enum(u16) {...@@ -1309,7 +1309,7 @@ pub const EM = enum(u16) {
1309 NS32K = 97,1309 NS32K = 97,
1310 /// Tenor Network TPC processor1310 /// Tenor Network TPC processor
1311 TPC = 98,1311 TPC = 98,
1312 /// Trebia SNP 1000 processor (also old value for picoJava; deprecated)1312 /// Trebia SNP 1000 processor (also old value for picoJava, which was not gABI assigned)
1313 SNP1K = 99,1313 SNP1K = 99,
1314 /// STMicroelectronics ST200 microcontroller1314 /// STMicroelectronics ST200 microcontroller
1315 ST200 = 100,1315 ST200 = 100,
...@@ -1341,7 +1341,7 @@ pub const EM = enum(u16) {...@@ -1341,7 +1341,7 @@ pub const EM = enum(u16) {
1341 ALTERA_NIOS2 = 113,1341 ALTERA_NIOS2 = 113,
1342 /// National Semiconductor CRX1342 /// National Semiconductor CRX
1343 CRX = 114,1343 CRX = 114,
1344 /// Motorola XGATE embedded processor (also old value for National Semiconductor CompactRISC; deprecated)1344 /// Motorola XGATE embedded processor (also old value for National Semiconductor CompactRISC, which was not gABI assigned)
1345 XGATE = 115,1345 XGATE = 115,
1346 /// Infineon C16x/XC16x processor1346 /// Infineon C16x/XC16x processor
1347 C166 = 116,1347 C166 = 116,
...@@ -1377,6 +1377,8 @@ pub const EM = enum(u16) {...@@ -1377,6 +1377,8 @@ pub const EM = enum(u16) {
1377 TI_C2000 = 141,1377 TI_C2000 = 141,
1378 /// Texas Instruments TMS320C55x DSP family1378 /// Texas Instruments TMS320C55x DSP family
1379 TI_C5500 = 142,1379 TI_C5500 = 142,
1380 /// Texas Instruments Application Specific RISC Processor, 32bit fetch
1381 TI_ARP32 = 143,
1380 /// Texas Instruments Programmable Realtime Unit1382 /// Texas Instruments Programmable Realtime Unit
1381 TI_PRU = 144,1383 TI_PRU = 144,
1382 /// STMicroelectronics 64bit VLIW Data Signal Processor1384 /// STMicroelectronics 64bit VLIW Data Signal Processor
...@@ -1537,6 +1539,18 @@ pub const EM = enum(u16) {...@@ -1537,6 +1539,18 @@ pub const EM = enum(u16) {
1537 TACHYUM = 261,1539 TACHYUM = 261,
1538 /// NXP 56800EF Digital Signal Controller (DSC)1540 /// NXP 56800EF Digital Signal Controller (DSC)
1539 @"56800EF" = 262,1541 @"56800EF" = 262,
1542 /// Solana Bytecode Format
1543 SBF = 263,
1544 /// AMD/Xilinx AIEngine architecture
1545 AIENGINE = 264,
1546 /// SiMa MLA
1547 SIMA_MLA = 265,
1548 /// Cambricon BANG
1549 BANG = 266,
1550 /// Loongson LoongGPU
1551 LOONGGPU = 267,
1552 /// Wuxi Institute of Advanced Technology SW64
1553 SW64 = 268,
1540 /// AVR1554 /// AVR
1541 AVR_OLD = 0x1057,1555 AVR_OLD = 0x1057,
1542 /// MSP4301556 /// MSP430
...@@ -2289,7 +2303,7 @@ pub const R_PPC64 = enum(u32) {...@@ -2289,7 +2303,7 @@ pub const R_PPC64 = enum(u32) {
2289 _,2303 _,
2290};2304};
22912305
2292pub const STV = enum(u2) {2306pub const STV = enum(u3) {
2293 DEFAULT = 0,2307 DEFAULT = 0,
2294 INTERNAL = 1,2308 INTERNAL = 1,
2295 HIDDEN = 2,2309 HIDDEN = 2,
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;
tools/gen_stubs.zig+1-1
...@@ -608,7 +608,7 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian)...@@ -608,7 +608,7 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian)
608 const name = try arena.dupe(u8, mem.sliceTo(dynstr[s(sym.st_name)..], 0));608 const name = try arena.dupe(u8, mem.sliceTo(dynstr[s(sym.st_name)..], 0));
609 const ty = @as(u4, @truncate(sym.st_info));609 const ty = @as(u4, @truncate(sym.st_info));
610 const binding = @as(u4, @truncate(sym.st_info >> 4));610 const binding = @as(u4, @truncate(sym.st_info >> 4));
611 const visib = @as(elf.STV, @enumFromInt(@as(u2, @truncate(sym.st_other))));611 const visib = @as(elf.STV, @enumFromInt(@as(u3, @truncate(sym.st_other))));
612 const size = s(sym.st_size);612 const size = s(sym.st_size);
613613
614 if (size == 0) {614 if (size == 0) {