authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-03-27 15:39:24+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-03-27 15:39:24+01:00
logcc9634a2d3ac3ee7ec36e16ab9117aad6e2da625
tree8b313771a3ddd68ea00593dae43d98526d414188
parentb5a5260546ddd8953e493f75c5ee12c5a853263b
parentb9efdbb412fa9e5691553eca49aacd31e9d7ff69
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #23373 from alexrp/get-base-address

`std.process`: Some minor fixes for `getBaseAddress()`

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

lib/std/process.zig+4-3
......@@ -1652,14 +1652,15 @@ 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 },
1662 .macos, .freebsd, .netbsd => {
1663 .driverkit, .ios, .macos, .tvos, .visionos, .watchos => {
16631664 return @intFromPtr(&std.c._mh_execute_header);
16641665 },
16651666 .windows => return @intFromPtr(windows.kernel32.GetModuleHandleW(null)),