getsockname on x64
get socket name
sys_getsockname(int fd, struct sockaddr *usockaddr, int *usockaddr_len)
| number | 51 (0x33) |
|---|---|
| abi | common |
| entry point | sys_getsockname |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | getsockname(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 51, the syscall number |
rdi | int fd |
rsi | struct sockaddr *usockaddr |
rdx | int *usockaddr_len |
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 367
- arm64 204
- arm 286
- riscv64 204
- ia32 367
- x32 1073741875
- loongarch64 204
- ppc64 331
- ppc 331
- s390x 367
- mips64 5050
- mipsn32 6050
- mipso32 4172
- alpha 150
- arc 204
- blackfin 318, removed in 4.17
- csky 204
- hexagon 204
- ia64 1195, removed in 6.7
- m68k 364
- metag 204, removed in 4.17
- microblaze 351
- nds32 204, removed in 5.18
- nios2 204
- openrisc 204
- parisc 44
- score 204, removed in 4.17
- sh 345
- sparc 150
- sparc64 150
- tilegx 204, removed in 4.17
- tilepro 204, removed in 4.17
- xtensa 104
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/getsockname