Why stack up on a function call?

I looked at the function call parsing and found this:

movq %rsp, %rbp pushq %rbx subq $136, %rsp ; Pad the stack .... addq $136, %rsp ; Unpad the stack popq %rbx popq %rbp ret 

What is the value of this?

+6
source share
1 answer

This is a space for local variables, not padding.

The compiler will create this stack space for any spills of registers and local variables that it must store during the execution of this function.

When parsing x86-64 code using SysV ABI (most things that are not Windows, I don’t know how this happens in the latter), you can see some additions, since function calls must have a 16-byte stack alignment. But in this case, it actually reserves space for local variables.

You can look at this or find more information on how compilers work.

+12
source

Source: https://habr.com/ru/post/970961/


All Articles