authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-07 16:07:51+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-07 22:13:05+01:00
loga779450fefd623c54da37912995ffe7ad16b514e
treee6d0338cf64cd1a855f770926a98ff3390e0e732
parent7a58ec81ecfbf64baabdf883a458ca7296a34fc7

linux/i386: Make syscall6 more robust and correct

LLVM10 exposed a subtle flaw in the previous implementation that made the mmap tests fail.

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

lib/std/os/linux/i386.zig+10-4
......@@ -72,11 +72,17 @@ pub fn syscall6(
7272 arg5: usize,
7373 arg6: usize,
7474) usize {
75 // The 6th argument is passed via memory as we're out of registers if ebp is
76 // used as frame pointer. We push arg6 value on the stack before changing
77 // ebp or esp as the compiler may reference it as an offset relative to one
78 // of those two registers.
7579 return asm volatile (
76 \\ push %%ebp
77 \\ mov %[arg6], %%ebp
78 \\ int $0x80
79 \\ pop %%ebp
80 \\ push %[arg6]
81 \\ push %%ebp
82 \\ mov 4(%%esp), %%ebp
83 \\ int $0x80
84 \\ pop %%ebp
85 \\ add $4, %%esp
8086 : [ret] "={eax}" (-> usize)
8187 : [number] "{eax}" (number),
8288 [arg1] "{ebx}" (arg1),