Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's on the stack when a function is called?

I can only imagine 1) parameters; 2) local variables;

what else?

1) function return address? 2) function name?

like image 392
skydoor Avatar asked Aug 23 '26 23:08

skydoor


1 Answers

It really depends on platform and architecture, but typically:

  • Function return address
  • Saved values of caller's CPU registers - most importantly, caller's stack frame pointer value
  • Variables allocated with alloca().
  • Sometimes - extra stuff for exception handling, this is VERY platform-dependent.
  • Sometimes - guard values to detect stack clobbering

Function name is never in the stack, to the best of my knowledge, unless your code places it there.

like image 161
Seva Alekseyev Avatar answered Aug 25 '26 12:08

Seva Alekseyev



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!