| ... | ... | @@ -85,24 +85,27 @@ pub fn syscall6( |
| 85 | 85 | arg5: usize, |
| 86 | 86 | arg6: usize, |
| 87 | 87 | ) usize { |
| 88 | | // The 6th argument is passed via memory as we're out of registers if ebp is |
| 89 | | // used as frame pointer. We push arg6 value on the stack before changing |
| 90 | | // ebp or esp as the compiler may reference it as an offset relative to one |
| 91 | | // of those two registers. |
| 88 | // arg5/arg6 are passed via memory as we're out of registers if ebp is used as frame pointer, or |
| 89 | // if we're compiling with PIC. We push arg5/arg6 on the stack before changing ebp/esp as the |
| 90 | // compiler may reference arg5/arg6 as an offset relative to ebp/esp. |
| 92 | 91 | return asm volatile ( |
| 92 | \\ push %[arg5] |
| 93 | 93 | \\ push %[arg6] |
| 94 | \\ push %%edi |
| 94 | 95 | \\ push %%ebp |
| 95 | | \\ mov 4(%%esp), %%ebp |
| 96 | \\ mov 12(%%esp), %%edi |
| 97 | \\ mov 8(%%esp), %%ebp |
| 96 | 98 | \\ int $0x80 |
| 97 | 99 | \\ pop %%ebp |
| 98 | | \\ add $4, %%esp |
| 100 | \\ pop %%edi |
| 101 | \\ add $8, %%esp |
| 99 | 102 | : [ret] "={eax}" (-> usize), |
| 100 | 103 | : [number] "{eax}" (@intFromEnum(number)), |
| 101 | 104 | [arg1] "{ebx}" (arg1), |
| 102 | 105 | [arg2] "{ecx}" (arg2), |
| 103 | 106 | [arg3] "{edx}" (arg3), |
| 104 | 107 | [arg4] "{esi}" (arg4), |
| 105 | | [arg5] "{edi}" (arg5), |
| 108 | [arg5] "rm" (arg5), |
| 106 | 109 | [arg6] "rm" (arg6), |
| 107 | 110 | : "memory" |
| 108 | 111 | ); |