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

ELF updates for gABI 4.3
This commit is contained in:
Alex Rønne Petersen 2025-09-04 10:58:28 +02:00 committed by GitHub
commit d94e061ade
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 34 additions and 20 deletions

View File

@ -2226,7 +2226,7 @@ const ElfDumper = struct {
try writer.print(" {s}", .{sym_bind}); try writer.print(" {s}", .{sym_bind});
} }
const sym_vis = @as(elf.STV, @enumFromInt(@as(u2, @truncate(sym.st_other)))); const sym_vis = @as(elf.STV, @enumFromInt(@as(u3, @truncate(sym.st_other))));
try writer.print(" {s}", .{@tagName(sym_vis)}); try writer.print(" {s}", .{@tagName(sym_vis)});
const sym_name = switch (sym.st_type()) { const sym_name = switch (sym.st_type()) {

View File

@ -1122,17 +1122,17 @@ pub const OSABI = enum(u8) {
CLOUDABI = 17, CLOUDABI = 17,
/// Stratus Technologies OpenVOS /// Stratus Technologies OpenVOS
OPENVOS = 18, OPENVOS = 18,
/// NVIDIA CUDA architecture /// NVIDIA CUDA architecture (not gABI assigned)
CUDA = 51, CUDA = 51,
/// AMD HSA Runtime /// AMD HSA Runtime (not gABI assigned)
AMDGPU_HSA = 64, AMDGPU_HSA = 64,
/// AMD PAL Runtime /// AMD PAL Runtime (not gABI assigned)
AMDGPU_PAL = 65, AMDGPU_PAL = 65,
/// AMD Mesa3D Runtime /// AMD Mesa3D Runtime (not gABI assigned)
AMDGPU_MESA3D = 66, AMDGPU_MESA3D = 66,
/// ARM /// ARM (not gABI assigned)
ARM = 97, ARM = 97,
/// Standalone (embedded) application /// Standalone (embedded) application (not gABI assigned)
STANDALONE = 255, STANDALONE = 255,
_, _,
@ -1165,11 +1165,11 @@ pub const EM = enum(u16) {
S370 = 9, S370 = 9,
/// MIPS R3000 (and R4000) little-endian, Oct 4 1993 Draft (deprecated) /// MIPS R3000 (and R4000) little-endian, Oct 4 1993 Draft (deprecated)
MIPS_RS3_LE = 10, MIPS_RS3_LE = 10,
/// Old version of Sparc v9, from before the ABI (deprecated) /// Old version of Sparc v9, from before the ABI (not gABI assigned)
OLD_SPARCV9 = 11, OLD_SPARCV9 = 11,
/// HPPA /// HPPA
PARISC = 15, PARISC = 15,
/// Fujitsu VPP500 (also old version of PowerPC; deprecated) /// Fujitsu VPP500 (also old version of PowerPC, which was not gABI assigned)
VPP500 = 17, VPP500 = 17,
/// Sun's "v8plus" /// Sun's "v8plus"
SPARC32PLUS = 18, SPARC32PLUS = 18,
@ -1189,7 +1189,7 @@ pub const EM = enum(u16) {
FR20 = 37, FR20 = 37,
/// TRW RH32 /// TRW RH32
RH32 = 38, RH32 = 38,
/// Motorola M*Core, aka RCE (also Fujitsu MMA) /// Motorola M*Core, aka RCE (also old Fujitsu MMA, which was not gABI assigned)
MCORE = 39, MCORE = 39,
/// ARM /// ARM
ARM = 40, ARM = 40,
@ -1301,7 +1301,7 @@ pub const EM = enum(u16) {
ARC_COMPACT = 93, ARC_COMPACT = 93,
/// Tensilica Xtensa Architecture /// Tensilica Xtensa Architecture
XTENSA = 94, XTENSA = 94,
/// Alphamosaic VideoCore processor (also old Sunplus S+core7 backend magic number) /// Alphamosaic VideoCore processor (also old Sunplus S+core7 backend magic number, which was not gABI assigned)
VIDEOCORE = 95, VIDEOCORE = 95,
/// Thompson Multimedia General Purpose Processor /// Thompson Multimedia General Purpose Processor
TMM_GPP = 96, TMM_GPP = 96,
@ -1309,7 +1309,7 @@ pub const EM = enum(u16) {
NS32K = 97, NS32K = 97,
/// Tenor Network TPC processor /// Tenor Network TPC processor
TPC = 98, TPC = 98,
/// Trebia SNP 1000 processor (also old value for picoJava; deprecated) /// Trebia SNP 1000 processor (also old value for picoJava, which was not gABI assigned)
SNP1K = 99, SNP1K = 99,
/// STMicroelectronics ST200 microcontroller /// STMicroelectronics ST200 microcontroller
ST200 = 100, ST200 = 100,
@ -1341,7 +1341,7 @@ pub const EM = enum(u16) {
ALTERA_NIOS2 = 113, ALTERA_NIOS2 = 113,
/// National Semiconductor CRX /// National Semiconductor CRX
CRX = 114, CRX = 114,
/// Motorola XGATE embedded processor (also old value for National Semiconductor CompactRISC; deprecated) /// Motorola XGATE embedded processor (also old value for National Semiconductor CompactRISC, which was not gABI assigned)
XGATE = 115, XGATE = 115,
/// Infineon C16x/XC16x processor /// Infineon C16x/XC16x processor
C166 = 116, C166 = 116,
@ -1377,6 +1377,8 @@ pub const EM = enum(u16) {
TI_C2000 = 141, TI_C2000 = 141,
/// Texas Instruments TMS320C55x DSP family /// Texas Instruments TMS320C55x DSP family
TI_C5500 = 142, TI_C5500 = 142,
/// Texas Instruments Application Specific RISC Processor, 32bit fetch
TI_ARP32 = 143,
/// Texas Instruments Programmable Realtime Unit /// Texas Instruments Programmable Realtime Unit
TI_PRU = 144, TI_PRU = 144,
/// STMicroelectronics 64bit VLIW Data Signal Processor /// STMicroelectronics 64bit VLIW Data Signal Processor
@ -1537,6 +1539,18 @@ pub const EM = enum(u16) {
TACHYUM = 261, TACHYUM = 261,
/// NXP 56800EF Digital Signal Controller (DSC) /// NXP 56800EF Digital Signal Controller (DSC)
@"56800EF" = 262, @"56800EF" = 262,
/// Solana Bytecode Format
SBF = 263,
/// AMD/Xilinx AIEngine architecture
AIENGINE = 264,
/// SiMa MLA
SIMA_MLA = 265,
/// Cambricon BANG
BANG = 266,
/// Loongson LoongGPU
LOONGGPU = 267,
/// Wuxi Institute of Advanced Technology SW64
SW64 = 268,
/// AVR /// AVR
AVR_OLD = 0x1057, AVR_OLD = 0x1057,
/// MSP430 /// MSP430
@ -2289,7 +2303,7 @@ pub const R_PPC64 = enum(u32) {
_, _,
}; };
pub const STV = enum(u2) { pub const STV = enum(u3) {
DEFAULT = 0, DEFAULT = 0,
INTERNAL = 1, INTERNAL = 1,
HIDDEN = 2, HIDDEN = 2,

View File

@ -634,7 +634,7 @@ pub fn claimUnresolved(self: *Object, elf_file: *Elf) void {
const is_import = blk: { const is_import = blk: {
if (!elf_file.isEffectivelyDynLib()) break :blk false; if (!elf_file.isEffectivelyDynLib()) break :blk false;
const vis = @as(elf.STV, @enumFromInt(esym.st_other)); const vis: elf.STV = @enumFromInt(@as(u3, @truncate(esym.st_other)));
if (vis == .HIDDEN) break :blk false; if (vis == .HIDDEN) break :blk false;
break :blk true; break :blk true;
}; };
@ -707,7 +707,7 @@ pub fn markImportsExports(self: *Object, elf_file: *Elf) void {
const file = sym.file(elf_file).?; const file = sym.file(elf_file).?;
// https://github.com/ziglang/zig/issues/21678 // https://github.com/ziglang/zig/issues/21678
if (@as(u16, @bitCast(sym.version_index)) == @as(u16, @bitCast(elf.Versym.LOCAL))) continue; if (@as(u16, @bitCast(sym.version_index)) == @as(u16, @bitCast(elf.Versym.LOCAL))) continue;
const vis: elf.STV = @enumFromInt(sym.elfSym(elf_file).st_other); const vis: elf.STV = @enumFromInt(@as(u3, @truncate(sym.elfSym(elf_file).st_other)));
if (vis == .HIDDEN) continue; if (vis == .HIDDEN) continue;
if (file == .shared_object and !sym.isAbs(elf_file)) { if (file == .shared_object and !sym.isAbs(elf_file)) {
sym.flags.import = true; sym.flags.import = true;

View File

@ -357,7 +357,7 @@ pub fn markImportExports(self: *SharedObject, elf_file: *Elf) void {
const ref = self.resolveSymbol(@intCast(i), elf_file); const ref = self.resolveSymbol(@intCast(i), elf_file);
const ref_sym = elf_file.symbol(ref) orelse continue; const ref_sym = elf_file.symbol(ref) orelse continue;
const ref_file = ref_sym.file(elf_file).?; const ref_file = ref_sym.file(elf_file).?;
const vis = @as(elf.STV, @enumFromInt(ref_sym.elfSym(elf_file).st_other)); const vis: elf.STV = @enumFromInt(@as(u3, @truncate(ref_sym.elfSym(elf_file).st_other)));
if (ref_file != .shared_object and vis != .HIDDEN) ref_sym.flags.@"export" = true; if (ref_file != .shared_object and vis != .HIDDEN) ref_sym.flags.@"export" = true;
} }
} }

View File

@ -617,7 +617,7 @@ pub fn claimUnresolved(self: *ZigObject, elf_file: *Elf) void {
const is_import = blk: { const is_import = blk: {
if (!elf_file.isEffectivelyDynLib()) break :blk false; if (!elf_file.isEffectivelyDynLib()) break :blk false;
const vis = @as(elf.STV, @enumFromInt(esym.st_other)); const vis: elf.STV = @enumFromInt(@as(u3, @truncate(esym.st_other)));
if (vis == .HIDDEN) break :blk false; if (vis == .HIDDEN) break :blk false;
break :blk true; break :blk true;
}; };
@ -695,7 +695,7 @@ pub fn markImportsExports(self: *ZigObject, elf_file: *Elf) void {
const file = sym.file(elf_file).?; const file = sym.file(elf_file).?;
// https://github.com/ziglang/zig/issues/21678 // https://github.com/ziglang/zig/issues/21678
if (@as(u16, @bitCast(sym.version_index)) == @as(u16, @bitCast(elf.Versym.LOCAL))) continue; if (@as(u16, @bitCast(sym.version_index)) == @as(u16, @bitCast(elf.Versym.LOCAL))) continue;
const vis: elf.STV = @enumFromInt(sym.elfSym(elf_file).st_other); const vis: elf.STV = @enumFromInt(@as(u3, @truncate(sym.elfSym(elf_file).st_other)));
if (vis == .HIDDEN) continue; if (vis == .HIDDEN) continue;
if (file == .shared_object and !sym.isAbs(elf_file)) { if (file == .shared_object and !sym.isAbs(elf_file)) {
sym.flags.import = true; sym.flags.import = true;

View File

@ -608,7 +608,7 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian)
const name = try arena.dupe(u8, mem.sliceTo(dynstr[s(sym.st_name)..], 0)); const name = try arena.dupe(u8, mem.sliceTo(dynstr[s(sym.st_name)..], 0));
const ty = @as(u4, @truncate(sym.st_info)); const ty = @as(u4, @truncate(sym.st_info));
const binding = @as(u4, @truncate(sym.st_info >> 4)); const binding = @as(u4, @truncate(sym.st_info >> 4));
const visib = @as(elf.STV, @enumFromInt(@as(u2, @truncate(sym.st_other)))); const visib = @as(elf.STV, @enumFromInt(@as(u3, @truncate(sym.st_other))));
const size = s(sym.st_size); const size = s(sym.st_size);
if (size == 0) { if (size == 0) {