getpeername on x64
get name of connected peer socket
sys_getpeername(int fd, struct sockaddr *usockaddr, int *usockaddr_len)
| number | 52 (0x34) |
|---|---|
| abi | common |
| entry point | sys_getpeername |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | getpeername(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 52, 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 368
- arm64 205
- arm 287
- riscv64 205
- ia32 368
- x32 1073741876
- loongarch64 205
- ppc64 332
- ppc 332
- s390x 368
- mips64 5051
- mipsn32 6051
- mipso32 4171
- alpha 141
- arc 205
- blackfin 317, removed in 4.17
- csky 205
- hexagon 205
- ia64 1196, removed in 6.7
- m68k 365
- metag 205, removed in 4.17
- microblaze 352
- nds32 205, removed in 5.18
- nios2 205
- openrisc 205
- parisc 53
- score 205, removed in 4.17
- sh 346
- sparc 141
- sparc64 141
- tilegx 205, removed in 4.17
- tilepro 205, removed in 4.17
- xtensa 105
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/getpeername