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 {...@@ -1652,11 +1652,12 @@ pub fn posixGetUserInfo(name: []const u8) !UserInfo {
1652pub fn getBaseAddress() usize {1652pub fn getBaseAddress() usize {
1653 switch (native_os) {1653 switch (native_os) {
1654 .linux => {1654 .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);
1656 if (base != 0) {1657 if (base != 0) {
1657 return base;1658 return base;
1658 }1659 }
1659 const phdr = std.os.linux.getauxval(std.elf.AT_PHDR);1660 const phdr = getauxval(std.elf.AT_PHDR);
1660 return phdr - @sizeOf(std.elf.Ehdr);1661 return phdr - @sizeOf(std.elf.Ehdr);
1661 },1662 },
1662 .macos, .freebsd, .netbsd => {1663 .macos, .freebsd, .netbsd => {