skip to Main Content

My system : Ubuntu 22.04.3 running on x86_64. GCC version 11.4.0

I’m asking this because it seems like there are two different representations of the return address as far as the frame it is within ( caller or callee ) is concerned.

This is what "Computer Systems, A Programmer’s Perspective" shows :

enter image description here

This is what "System V Application Binary Interface AMD64 Architecture Processor Supplement" shows :

enter image description here

As you can see in the System V ABI document representation we have the return address inside the current frame ( called/callee function ) but in the book representation it is in the caller frame ( caller function ).

Here are my questions :

  1. What representations is right ?

  2. Is the collocation of the return address inside a particular frame ( caller or callee ) just an arbitrary silly matter and not specified by any ABI ?

2

Answers


  1. Caller’s frame.

    See more details at Explanation needed for this assembler code

    Login or Signup to reply.
  2. The return address is pushed by the caller but popped by the callee upon function completion & return to caller, so that return address on the stack only exists for the duration of the callee’s activation.

    Because when the callee returns that return address is removed, and the caller doesn’t see or use it, I would argue that it is not part of the caller’s stack frame.  Therefore I would have to consider it a part of the callee’s frame

    As others say though, this is just semantics.  What matters is the operations (e.g. who pops) and the values (where addresses point).

    However, in general, to answer the question of which frame something belongs to, I would ask: how long does that storage last and who pops it off the stack (i.e. who is really responsible for that storage)?

    When a callee returns, what remains on the stack belongs to callers.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search