connect on x64
initiate a connection on a socket
sys_connect(int fd, struct sockaddr *uservaddr, int addrlen)
| number | 42 (0x2a) |
|---|---|
| abi | common |
| entry point | sys_connect |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | connect(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 42, the syscall number |
rdi | int fd |
rsi | struct sockaddr *uservaddr |
rdx | int addrlen |
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 362
- arm64 203
- arm 283
- riscv64 203
- ia32 362
- x32 1073741866
- loongarch64 203
- ppc64 328
- ppc 328
- s390x 362
- mips64 5041
- mipsn32 6041
- mipso32 4170
- alpha 98
- arc 203
- blackfin 316, removed in 4.17
- csky 203
- hexagon 203
- ia64 1192, removed in 6.7
- m68k 359
- metag 203, removed in 4.17
- microblaze 350
- nds32 203, removed in 5.18
- nios2 203
- openrisc 203
- parisc 31
- score 203, removed in 4.17
- sh 342
- sparc 98
- sparc64 98
- tilegx 203, removed in 4.17
- tilepro 203, removed in 4.17
- xtensa 101
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/connect