authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-01 04:34:32+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-03 00:57:34+02:00
log125c043abc208842cd7e1deb188136600eb5c3ea
treecf671ac0f2761993cf50215feb87b45106812abd
parentb569ead29ea4459d0d363bf5a878ddb53f8f14f3
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

link.Elf: Set EI_OSABI value correctly depending on target arch/OS.


1 files changed, 20 insertions(+), 3 deletions(-)

src/link/Elf.zig+20-3
...@@ -2589,11 +2589,28 @@ pub fn writeElfHeader(self: *Elf) !void {...@@ -2589,11 +2589,28 @@ pub fn writeElfHeader(self: *Elf) !void {
2589 hdr_buf[index] = 1; // ELF version2589 hdr_buf[index] = 1; // ELF version
2590 index += 1;2590 index += 1;
25912591
2592 // OS ABI, often set to 0 regardless of target platform2592 hdr_buf[index] = @intFromEnum(@as(elf.OSABI, switch (target.cpu.arch) {
2593 .amdgcn => switch (target.os.tag) {
2594 .amdhsa => .AMDGPU_HSA,
2595 .amdpal => .AMDGPU_PAL,
2596 .mesa3d => .AMDGPU_MESA3D,
2597 else => .NONE,
2598 },
2599 .msp430 => .STANDALONE,
2600 else => switch (target.os.tag) {
2601 .freebsd, .ps4 => .FREEBSD,
2602 .hermit => .STANDALONE,
2603 .illumos, .solaris => .SOLARIS,
2604 .openbsd => .OPENBSD,
2605 else => .NONE,
2606 },
2607 }));
2608 index += 1;
2609
2593 // ABI Version, possibly used by glibc but not by static executables2610 // ABI Version, possibly used by glibc but not by static executables
2594 // padding2611 // padding
2595 @memset(hdr_buf[index..][0..9], 0);2612 @memset(hdr_buf[index..][0..8], 0);
2596 index += 9;2613 index += 8;
25972614
2598 assert(index == 16);2615 assert(index == 16);
25992616