SLAA534A June 2013 – June 2020
Personality routines PR0, PR1, and PR2 use a byte-encoded sequence of instructions to describe how to unwind the frame. The first few instructions are packed into the three remaining bytes of the first word of the EXTAB; additional instructions are packed into subsequent words. Unused bytes in the last word are filled with “RET ” instructions.
Although the instructions are byte-encoded, they are always packed into 32-bit words starting at the MSB. As a consequence, the first unwinding instruction will not be at the lowest-addressed byte in little-endian mode.
Personality routine PR0 allows at most three unwinding instructions, all of which are stored in the first EXTAB word. If there are more than three unwinding instructions, one of the other personality routines must be used.
For PR1 and PR2, bits 23-16 encode the number of extra 32-bit words of unwinding instructions, which can be 0.
Table 9-2 summarizes the unwinding instruction set. Each instruction is described in more detail after the table.
Encoding | Instruction | Description |
---|---|---|
0xxx xxxx | POP bitmask (R10, R9, R8, R7, R6, R5, R4) + RET | Restore callee-saved registers and return. |
11kk kkkk | SP += (kkkkkk << 1) + 2 [0x02-0x80] | Increment by small constant |
1000 0001 kkkk .... | SP += (ULEB128 << 1) + 0x102 [0x102-max] | Increment by large constant |
1000 0000 0000 0000 | CANTUNWIND | Function cannot be unwound |
All other bit patterns are reserved.
The following paragraphs detail the interpretation of the unwinding instructions.
POP + RET
The POP+RET instruction specifies a bitmask representing registers saved by this function's prolog. These registers must be popped in order, starting with R4 and proceeding through R10. When that is done, there are no more unwinding instructions. If none of the bits in the bitmask are set, this is simply a RET instruction.
Small Increment
The value of k is extracted from the lower 6 bits of the encoding. This instruction can increment the SP by a value in the range 0x8 to 0x200, inclusive. Increments in the range 0x208 to 0x400 should be done with two of these instructions.
Large Increment
The value ULEB128 is ULEB128-encoded in the bytes following the 8-bit opcode. This instruction can increment the SP by a value of 0x408 or greater. Increments less than 0x408 should be done with one or two Small Increment instructions.
CANTUNWIND
This instruction indicates that the function cannot be unwound, usually because it is an interrupt function. However, an interrupt function can still have try/catch code, so EXIDX_CANTUNWIND is not appropriate.