ElBlo

TIL Linux Kernel x86 ABI

On x86, the Linux Kernel uses a slightly different ABI that userspace linux for parameter passing on function calls. Instead of passing parameters via the stack in reverse order, it uses eax, edx and ecx for passing the first three parameters. This is done via the regparm compiler option12. I found out about this thanks to this helpful stackoverflow answer.


  1. https://clang.llvm.org/docs/AttributeReference.html#regparm ↩︎

  2. https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/x86-Options.html#:~:text=are%20harmlessly%20ignored.)-,-mregparm%3Dnum,-Control%20how%20many ↩︎

© Marco Vanotti 2024

Powered by Hugo & new.css.