Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

push return values in stack frame

I'm wondering if it makes sense to push the return value of a function in its the stack-frame.

I know return values are mostly stored in registers (eax for gcc), but is it for performance only?

Thanks!

like image 609
ms123 Avatar asked Jan 19 '23 01:01

ms123


1 Answers

it makes sense, but it must be manually inserted (and not a simple push). the 'space' for it should be 'allocated' by the caller (it must decrease sp before calling the function) because when you return from the function - the return address must be at the top of the stack, so the return value should be below the return address. [same principle as passing arguments on stack]

like image 149
amit Avatar answered Jan 25 '23 06:01

amit