Monday, February 5, 2024

[SOLVED] What registers are preserved through a linux x86-64 function call

Issue

I believe I understand how the linux x86-64 ABI uses registers and stack to pass parameters to a function (cf. href="https://stackoverflow.com/questions/2535989/what-are-the-calling-conventions-for-unix-linux-system-calls-on-x86-64/2538212#2538212">previous ABI discussion). What I'm confused about is if/what registers are expected to be preserved across a function call. That is, what registers are guaranteed not to get clobbered?


Solution

Here's the complete table of registers and their use from the documentation [PDF Link]:

table from docs

r12, r13, r14, r15, rbx, rsp, rbp are the callee-saved registers - they have a "Yes" in the "Preserved across function calls" column.



Answered By - Carl Norum
Answer Checked By - Mary Flores (WPSolving Volunteer)