readlink on x64
read value of a symbolic link
sys_readlink(const char *path, char *buf, int bufsiz)
| number | 89 (0x59) |
|---|---|
| abi | common |
| entry point | sys_readlink |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | readlink(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 89, the syscall number |
rdi | const char *path |
rsi | char *buf |
rdx | int bufsiz |
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 85
- arm 85
- ia32 85
- x32 1073741913
- ppc64 85
- ppc 85
- s390x 85
- mips64 5087
- mipsn32 6087
- mipso32 4085
- alpha 58
- blackfin 85, removed in 4.17
- cris 85, removed in 4.17
- frv 85, removed in 4.17
- ia64 1092, removed in 6.7
- m32r 85, removed in 4.17
- m68k 85
- microblaze 85
- mn10300 85, removed in 4.17
- parisc 85
- score 1035, removed in 4.17
- sh 85
- sparc 58
- sparc64 58
- xtensa 35
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/readlink