|
| 1 | +//! Syscall wrappers for 32-bit x86. |
| 2 | +//! |
| 3 | +//! This module is similar to the `nr_last` module, except specialized for |
| 4 | +//! 32-bit x86. |
| 5 | +//! |
| 6 | +//! The syscall convention passes all arguments in registers. The closest we |
| 7 | +//! can easily get to that from Rust is to use the fastcall convention which |
| 8 | +//! passes the first two arguments in `ecx` and `edx`, which are the second |
| 9 | +//! and third Linux syscall arguments. To line them up, this function passes |
| 10 | +//! the second and third syscall argument as the first and second argument to |
| 11 | +//! the outline assembly, followed by the first syscall argument, and then the |
| 12 | +//! rest of the syscall arguments. The assembly code still has to do some work, |
| 13 | +//! but at least we can get up to two arguments into the right place for it. |
| 14 | +
|
1 | 15 | #![allow(dead_code, unused_imports)]
|
2 | 16 |
|
3 | 17 | use crate::imp::reg::{ArgReg, RetReg, SyscallNumber, A0, A1, A2, A3, A4, A5, R0};
|
4 | 18 | use crate::imp::vdso_wrappers::SyscallType;
|
5 | 19 |
|
6 |
| -// x86 (using fastcall) prefers to pass a1 and a2 first, before a0, because |
7 |
| -// fastcall passes the first two arguments in ecx and edx, which are the second |
8 |
| -// and third Linux syscall arguments. |
9 |
| -// |
10 | 20 | // First we declare the actual assembly routines with `*_nr_last_fastcall`
|
11 | 21 | // names and reordered arguments. If the signatures or calling conventions are
|
12 | 22 | // ever changed, the symbol names should also be updated accordingly, to avoid
|
@@ -128,8 +138,9 @@ pub(in crate::imp) unsafe fn syscall6(
|
128 | 138 | rustix_syscall6_nr_last_fastcall(a1, a2, a0, a3, a4, a5, nr)
|
129 | 139 | }
|
130 | 140 |
|
131 |
| -// We don't have separate `_readonly` implementations, so these can just be |
132 |
| -// aliases to their non-`_readonly` counterparts. |
| 141 | +// Then we define the `_readonly` versions of the wrappers. We don't have |
| 142 | +// separate `_readonly` implementations, so these can just be aliases to |
| 143 | +// their non-`_readonly` counterparts. |
133 | 144 | pub(in crate::imp) use {
|
134 | 145 | syscall0 as syscall0_readonly, syscall1 as syscall1_readonly, syscall2 as syscall2_readonly,
|
135 | 146 | syscall3 as syscall3_readonly, syscall4 as syscall4_readonly, syscall5 as syscall5_readonly,
|
|
0 commit comments