What are functional epilogues and prologues?

While reading some calling conventions in some processor architecture, I read something like

"epilogue and prologue" when a function is called from another function.

What is a prologue or epilogue of function?

+4
source share
2 answers

The epilogue and prologue of a function is simply a set of instructions that "set up" the context for the function when it is called and cleared when it returns.

A prolog typically performs tasks such as:

  • saves any registers that the function can use (which are required by the platform standard for saving in function calls)
  • allocates storage on the stack, which may be required for local variables
  • sets any pointer (or other link) to parameters that can be passed to the stack

Typically, the epilogue should restore any save registers and restore the stack pointer so that any memory reserved by the function for its own use is β€œfreed”.

The exact mechanisms that can be used in the prolog / epilogue depend on the processor architecture, standard platforms, arguments and return values ​​of the function, and the specific calling convention that the function can use.

+8
source

Wikipedia FTW: https://en.wikipedia.org/wiki/Function_prologue

That seemed to explain it pretty well, in my opinion. If there is something incomprehensible, let me know and I can try to figure it out.

+2
source

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


All Articles