read on x64
read from a file descriptor
sys_read(unsigned int fd, char *buf, size_t count)
| number | 0 (0x0) |
|---|---|
| abi | common |
| entry point | sys_read |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | read(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 0, the syscall number |
rdi | unsigned int fd |
rsi | char *buf |
rdx | size_t count |
rax | the return value |
Then run syscall to enter the kernel.
The syscall instruction clobbers rcx (the return address lands in rcx) and r11 (the flags land in r11).
Since Linux 5.14 the kernel reads the syscall number from eax and ignores the upper 32 bits of rax. Older kernels fail with ENOSYS when those bits are not zero, and mov eax, N clears them, so it works on both.
Same syscall on other architectures
- x86 3
- arm64 63
- arm 3
- riscv64 63
- ia32 3
- x32 1073741824
- loongarch64 63
- ppc64 3
- ppc 3
- s390x 3
- mips64 5000
- mipsn32 6000
- mipso32 4003
- alpha 3
- arc 63
- blackfin 3, removed in 4.17
- cris 3, removed in 4.17
- csky 63
- frv 3, removed in 4.17
- hexagon 63
- ia64 1026, removed in 6.7
- m32r 3, removed in 4.17
- m68k 3
- metag 63, removed in 4.17
- microblaze 3
- mn10300 3, removed in 4.17
- nds32 63, removed in 5.18
- nios2 63
- openrisc 63
- parisc 3
- score 63, removed in 4.17
- sh 3
- sparc 3
- sparc64 3
- tilegx 63, removed in 4.17
- tilepro 63, removed in 4.17
- xtensa 12
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/read