Reputation: 999
Since x86-64 CPU can run x86-32 code directly, and write to eax
will zeros out the higher bits of rax
, so the syscall number will be right. What other job does the kernel have to do to run x86-32 program?
Upvotes: 3
Views: 362
Reputation: 37232
What other job does the kernel have to do to run x86-32 program?
All 64-bit parameters need to be split (e.g. passed in edx:eax
instead of just rax
). The mechanism used to call the kernel API is completely different (int 0x80
vs. syscall
). The stack layout (which matters for things like sending signals back to user-space signal handlers) is different. Virtual memory management has to be aware that user-space can't use 64-bit pointers. Different segment registers are used for TLS (gs
for 32-bit, fs
for 64-bit).
Mostly it's different enough that that you end up with completely separate system call entry/exit and dispatch code (where both interfaces call the same internal functions after parameters and calling conventions are handled).
Upvotes: 2