> What's up with the and rsp,0xfffffffffffffff0? That's because the function manually aligns the stack to the next 16-byte boundary. I'm not sure why the stdlib does this. The SystemV ABI (§2.3.1) guarantees an initial alignment of 16 already, so it should be superfluous.
Linux does not make any such guarantee, however; so in order for _start to call functions using the sysv ABI in a compliant fashion, it must provide them with an aligned stack.
Do you know offhand if the guarantees made by the Linux ELF loader is documented anywhere? I did search for it myself but didn't find anything authoritative.
There’s a walkthrough of the relevant kernel code in the superb “How programs get run” series[1], and it seems to try for 16-byte alignment on all platforms.
Normally this kind of thing would be in the relevant System V ABI Processor Supplement (officially, by way of the SVID and gABI, but everybody just refers to the psABI directly) [2], in the “Process Initialization” section (the above-mentioned §2.3), but note e.g. the story of how the GCC developers accidentally defaulted to a stricter alignment than the spec said and then decided to just run with it and rewrite the spec after the fact[3].
> What's up with the and rsp,0xfffffffffffffff0? That's because the function manually aligns the stack to the next 16-byte boundary. I'm not sure why the stdlib does this. The SystemV ABI (§2.3.1) guarantees an initial alignment of 16 already, so it should be superfluous.
Linux does not make any such guarantee, however; so in order for _start to call functions using the sysv ABI in a compliant fashion, it must provide them with an aligned stack.