Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux ARM64 calling convention: What registers need saving by callee?

Is there a list of registers that, on aarch64 Linux/BSD, the callee absolutely must save/restore if the callee is going to use them? The ABI documentation seemed muddled on this point. Or at least, it's nowhere as clear as the ABI documentation for other ISAs.

I'm asking for a list of specific 64-bit registers that need to be saved by the callee if they are going to be modified by the callee.

like image 978
Whuddawuh Avatar asked Oct 14 '25 07:10

Whuddawuh


1 Answers

Linux follows the AAPCS64 ABI, which mandates:

A subroutine invocation must preserve the contents of the registers r19-r29 and SP. All 64 bits of each value stored in r19-r29 must be preserved, even when using the ILP32 data model [...].

And for SIMD/floating-point:

Registers v8-v15 must be preserved by a callee across subroutine calls; [...]. Additionally, only the bottom 64 bits of each value stored in v8-v15 need to be preserved; it is the responsibility of the caller to preserve larger values.

like image 84
Siguza Avatar answered Oct 17 '25 00:10

Siguza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!