curiosity question about swapcontext libc implementation on x86_64
Godmar Back
godmar@gmail.com
Thu Feb 1 15:23:37 GMT 2024
The implementation of the obsolescent makecontext/getcontext/swapcontext
family of functions on x86_64 [1] appears to save a selection of registers.
These include callee-saved regs like rbx, rbp, r12-r15, but also
caller-saved regs like rdi, rsi, rdx, rcx. On the floating point side, it
saves mxcsr, the x87 FPU state via fnstenv, but not the xmm SSE register.
All of these floating point registers are callee-saved based on the AMD64
ABI [2].
It also saves/restores the current signal mask.
Does anyone know why it saves this set of registers/signal mask? Why does
it save callee-saved registers, but not all of them?
- Godmar
[1]
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86_64/swapcontext.S;h=b2e0f19a9d57e5007b094037b4cf59868029fc36;hb=HEAD
[2]
https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build
More information about the Libc-help
mailing list