shmget on x64
allocates a System V shared memory segment
sys_shmget(key_t key, size_t size, int flag)
| number | 29 (0x1d) |
|---|---|
| abi | common |
| kconfig | CONFIG_SYSVIPC |
| family | sysvipc see the whole family on x64 |
| entry point | sys_shmget |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | shmget(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 29, the syscall number |
rdi | key_t key |
rsi | size_t size |
rdx | int flag |
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 395
- arm64 194
- arm 307
- riscv64 194
- ia32 395
- x32 1073741853
- loongarch64 194
- ppc64 395
- ppc 395
- s390x 395
- mips64 5028
- mipsn32 6028
- mipso32 4395
- alpha 212
- arc 194
- blackfin 341, removed in 4.17
- csky 194
- hexagon 194
- ia64 1113, removed in 6.7
- m68k 395
- metag 194, removed in 4.17
- microblaze 338
- nds32 194, removed in 5.18
- nios2 194
- openrisc 194
- parisc 194
- score 194, removed in 4.17
- sh 395
- sparc 395
- sparc64 395
- tilegx 194, removed in 4.17
- tilepro 194, removed in 4.17
- xtensa 92
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/shmget