authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-03-26 18:26:48+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-03-26 20:39:07+01:00
log0cf5f0d0b085e66eb5421b5bb8a179d9b7fad6db
tree64ffbae1c26be295d20b35ec85415086208b305f
parentb84db311d90d722c206a7eea5464f46fd1b9e827
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.process: Fix getBaseAddress() for linux + libc.

In this case we should use the getauxval() from libc, not our own.

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

lib/std/process.zig+3-2
......@@ -1652,11 +1652,12 @@ pub fn posixGetUserInfo(name: []const u8) !UserInfo {
16521652pub fn getBaseAddress() usize {
16531653 switch (native_os) {
16541654 .linux => {
1655 const base = std.os.linux.getauxval(std.elf.AT_BASE);
1655 const getauxval = if (builtin.link_libc) std.c.getauxval else std.os.linux.getauxval;
1656 const base = getauxval(std.elf.AT_BASE);
16561657 if (base != 0) {
16571658 return base;
16581659 }
1659 const phdr = std.os.linux.getauxval(std.elf.AT_PHDR);
1660 const phdr = getauxval(std.elf.AT_PHDR);
16601661 return phdr - @sizeOf(std.elf.Ehdr);
16611662 },
16621663 .macos, .freebsd, .netbsd => {