Is RSP always a multiple of 16 in GCC at the entry (first intruction) of a function (with default options)? [duplicate]
Asked Answered
C

0

1

Due to the 16 bytes alignment by default, does this imply the assertion in my question ?

Cadent answered 2/12, 2021 at 1:9 Comment(3)
In short, the answer is yes, assuming you are using the SysV ABI. Section 3.2.2: "The end of the input argument area shall be aligned on a 16 byte boundary. In other words, the value (%rsp + 8) is always a multiple of 16 when control is transferred to the function entry point.". That is, rsp+8 should be a multiple of 16 before the call, and the call pushes 8 bytes, so at the entry point rsp itself is a multiple of 16.Charcuterie
Yes, whether the function is reached by tailcall jmp or by an actual call, or anything else, it has to be as if it was reached by a call that was done with an aligned RSP.Washrag
It would defeat the purpose of Why does the x86-64 / AMD64 System V ABI mandate a 16 byte stack alignment? if you were allowed to enter functions without RSP % 16 == 8.Washrag

© 2022 - 2024 — McMap. All rights reserved.