In this answer Segmentation fault on printf - NASM 64bit Linux the first author says when I allock stack the %rsp must keep multiple of 16 plus 8 because afterwards a function call will push address on stack , But In ABI ,it says rsp must be multiple of 16 in program entry, And When I really try I found keep rsp multiple of 16 plus 8 cause segmentation fault even when then I call printf@PLT afterwards,but Keep it multiple of 16 works, So what should I do for rsp when alloc stack ?
But In ABI ,it says rsp must be multiple of 16 in program entry
_start
is not a function. It's not call
ed by anything, there is no return address on the stack (just argc
and the actual argv[]
and envp[]
arrays).
Yes, on process entry RSP is already 16-byte aligned, ready for a function call.
I edited Jester's answer again on the question you linked to clarify it.
16-byte aligned before a call
is the requirement. You get back to that with an offset of 16 * n + 8
inside your function before another call, including any push
es.