getsockopt on x64
get and set options on sockets
sys_getsockopt(int fd, int level, int optname, char *optval, int *optlen)
| number | 55 (0x37) |
|---|---|
| abi | 64 |
| entry point | sys_getsockopt |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | getsockopt(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 55, the syscall number |
rdi | int fd |
rsi | int level |
rdx | int optname |
r10 | char *optval |
r8 | int *optlen |
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 365
- arm64 209
- arm 295
- riscv64 209
- ia32 365
- x32 1073741879, 1073742366
- loongarch64 209
- ppc64 340
- ppc 340
- s390x 365
- mips64 5054
- mipsn32 6054
- mipso32 4173
- alpha 118
- arc 209
- blackfin 319, removed in 4.17
- csky 209
- hexagon 209
- ia64 1204, removed in 6.7
- m68k 362
- metag 209, removed in 4.17
- microblaze 358
- nds32 209, removed in 5.18
- nios2 209
- openrisc 209
- parisc 182
- score 209, removed in 4.17
- sh 354
- sparc 118
- sparc64 118
- tilegx 209, removed in 4.17
- tilepro 209, removed in 4.17
- xtensa 98
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/getsockopt