aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/std/os/linux/vdso.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/std/os/linux/vdso.zig b/lib/std/os/linux/vdso.zig
index dc056ddba4..beb98a063d 100644
--- a/lib/std/os/linux/vdso.zig
+++ b/lib/std/os/linux/vdso.zig
@@ -22,6 +22,10 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
}) {
const this_ph = @intToPtr(*elf.Phdr, ph_addr);
switch (this_ph.p_type) {
+ // On WSL1 as well as older kernels, the VDSO ELF image is pre-linked in the upper half
+ // of the memory space (e.g. p_vaddr = 0xffffffffff700000 on WSL1).
+ // Wrapping operations are used on this line as well as subsequent calculations relative to base
+ // (lines 47, 78) to ensure no overflow check is tripped.
elf.PT_LOAD => base = vdso_addr +% this_ph.p_offset -% this_ph.p_vaddr,
elf.PT_DYNAMIC => maybe_dynv = @intToPtr([*]usize, vdso_addr + this_ph.p_offset),
else => {},