Share via


ARM Epilog

The ARM epilog is a contiguous sequence of instructions that restores the saved permanent registers, resets the stack pointer to its value on function entry, and returns to the function's calling function. When unwinding out of a function, the Virtual Unwinder must determine if the currently executed instruction is in the prolog or epilog. If the current point of control lies in either of these areas, special measures must be taken to unwind out of the function.

In addition, the Virtual Unwinder requires that an epilog follow standard guidelines. The following list shows the guidelines for implementing an epilog:

  • All parts are immediately contiguous, with no intervening instructions.

  • If a frame pointer is set up, the epilog will be a single instruction that uses the frame as the base and updates all nonvolatile registers, including the Program Counter and the stack.

    If no frame is set up, the epilog will consist of a stack unlink, if needed, followed by an instruction to restore multiple registers or to copy the link register R14 to the program counter.

    In a routine that does not modify any nonvolatile registers and is not inter-working, the epilog will contain only a copy of the link register to the program counter.

  • A routine whose last instruction is a branch to another routine may have an empty epilog if it does not modify any nonvolatile registers.

  • If the function establishes a frame pointer, R11 for an ARM epilog, the function must not modify the pointer value during the interval between the completion of the prolog's last instruction and the beginning of the execution of the first instruction of the epilog.

    If the function does not establish a frame pointer, the value of R13, the function must not modify the stack pointer during the interval between the completion of the prolog's last instruction and the beginning of the execution of the first instruction of the epilog.

    This enables the Virtual Unwinder to determine the value of either the stack pointer or frame pointer as of the end of the prolog, so that it may emulate the execution of the prolog in reverse.

  • The address contained in the stack pointer, which is always R13, must never be greater than the lowest address of any unrestored register value in the Register Save Area.

    This prevents the preserved values of the permanent registers from being corrupted by a context switch or any other asynchronous event that might occur during the execution of a prolog or epilog.

If execution is not in a prolog, the Virtual Unwinder must determine the current instruction state. If an instruction outside of a prolog is executing, the Virtual Unwinder will have to reverse-execute the prolog.

See Also

ARM Prolog and Epilog | ARM Prolog | THUMB Prolog | THUMB Epilog | ARM Prolog and Epilog Coding Examples

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.