sendmsg on x64
send a message on a socket
sys_sendmsg(int fd, struct user_msghdr *msg, unsigned int flags)
| number | 46 (0x2e) |
|---|---|
| abi | 64 |
| entry point | sys_sendmsg |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | sendmsg(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 46, the syscall number |
rdi | int fd |
rsi | struct user_msghdr *msg |
rdx | unsigned int flags |
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 370
- arm64 211
- arm 296
- riscv64 211
- ia32 370
- x32 1073742342
- loongarch64 211
- ppc64 341
- ppc 341
- s390x 370
- mips64 5045
- mipsn32 6045
- mipso32 4179
- alpha 114
- arc 211
- blackfin 325, removed in 4.17
- csky 211
- hexagon 211
- ia64 1205, removed in 6.7
- m68k 367
- metag 211, removed in 4.17
- microblaze 360
- nds32 211, removed in 5.18
- nios2 211
- openrisc 211
- parisc 183
- score 211, removed in 4.17
- sh 355
- sparc 114
- sparc64 114
- tilegx 211, removed in 4.17
- tilepro 211, removed in 4.17
- xtensa 106
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/sendmsg