From ed6418544c4af7a12bc36fe7c8ec0feac78776c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Thu, 27 Mar 2025 15:39:24 +0100 Subject: [PATCH] Merge pull request #23373 from alexrp/get-base-address `std.process`: Some minor fixes for `getBaseAddress()` --- lib/std/process.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/std/process.zig b/lib/std/process.zig index dd08e88af2..ebc8de28b7 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -1651,14 +1651,15 @@ pub fn posixGetUserInfo(name: []const u8) !UserInfo { pub fn getBaseAddress() usize { switch (native_os) { .linux => { - const base = std.os.linux.getauxval(std.elf.AT_BASE); + const getauxval = if (builtin.link_libc) std.c.getauxval else std.os.linux.getauxval; + const base = getauxval(std.elf.AT_BASE); if (base != 0) { return base; } - const phdr = std.os.linux.getauxval(std.elf.AT_PHDR); + const phdr = getauxval(std.elf.AT_PHDR); return phdr - @sizeOf(std.elf.Ehdr); }, - .macos, .freebsd, .netbsd => { + .driverkit, .ios, .macos, .tvos, .visionos, .watchos => { return @intFromPtr(&std.c._mh_execute_header); }, .windows => return @intFromPtr(windows.kernel32.GetModuleHandleW(null)),