zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit a779450fefd623c54da37912995ffe7ad16b514e (tree)
parent 7a58ec81ecfbf64baabdf883a458ca7296a34fc7
Author: LemonBoy <thatlemon@gmail.com>
Date:   Fri,  7 Feb 2020 16:07:51 +0100

linux/i386: Make syscall6 more robust and correct

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

Diffstat:
Mlib/std/os/linux/i386.zig | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/std/os/linux/i386.zig b/lib/std/os/linux/i386.zig @@ -72,11 +72,17 @@ pub fn syscall6( arg5: usize, arg6: usize, ) usize { + // The 6th argument is passed via memory as we're out of registers if ebp is + // used as frame pointer. We push arg6 value on the stack before changing + // ebp or esp as the compiler may reference it as an offset relative to one + // of those two registers. return asm volatile ( - \\ push %%ebp - \\ mov %[arg6], %%ebp - \\ int $0x80 - \\ pop %%ebp + \\ push %[arg6] + \\ push %%ebp + \\ mov 4(%%esp), %%ebp + \\ int $0x80 + \\ pop %%ebp + \\ add $4, %%esp : [ret] "={eax}" (-> usize) : [number] "{eax}" (number), [arg1] "{ebx}" (arg1),