From 560043dadfa8bf3a6c15d7f09bfbc60e48e0084c Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 23 Nov 2020 12:00:12 +0100 Subject: Fix logic for detecting _DYNAMIC symbol Prevent spurious crashes for non-PIE executables. --- lib/std/process.zig | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/std/process.zig') diff --git a/lib/std/process.zig b/lib/std/process.zig index b083126b31..5fc262e8b0 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -686,6 +686,8 @@ pub fn getBaseAddress() usize { if (base != 0) { return base; } + // XXX: Wrong for PIE executables, it should look at the difference + // between _DYNAMIC and the PT_DYNAMIC phdr instead. const phdr = os.system.getauxval(std.elf.AT_PHDR); return phdr - @sizeOf(std.elf.Ehdr); }, -- cgit v1.2.3