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(...@@ -72,11 +72,17 @@ pub fn syscall6(
72 arg5: usize,72 arg5: usize,
73 arg6: usize,73 arg6: usize,
74) usize {74) 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.
75 return asm volatile (79 return asm volatile (
76 \\ push %%ebp80 \\ push %[arg6]
77 \\ mov %[arg6], %%ebp81 \\ push %%ebp
78 \\ int $0x8082 \\ mov 4(%%esp), %%ebp
79 \\ pop %%ebp83 \\ int $0x80
84 \\ pop %%ebp
85 \\ add $4, %%esp
80 : [ret] "={eax}" (-> usize)86 : [ret] "={eax}" (-> usize)
81 : [number] "{eax}" (number),87 : [number] "{eax}" (number),
82 [arg1] "{ebx}" (arg1),88 [arg1] "{ebx}" (arg1),