28.01.2015 Views

Exception Handling ABI for the ARM Architecture

Exception Handling ABI for the ARM Architecture

Exception Handling ABI for the ARM Architecture

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Exception</strong> handling <strong>ABI</strong> <strong>for</strong> <strong>the</strong> <strong>ARM</strong> architecture<br />

9 <strong>ARM</strong>-DEFINED PERSONALITY ROUTINES AND TABLE<br />

FORMATS FOR C AND C++<br />

9.1 Constraints on use<br />

The language-independent run-time support code <strong>for</strong> this scheme can be distributed freely in binary <strong>for</strong>m, so 3 rd<br />

parties are encouraged to generate tables compatible with it. (Aside: Every language-specific run-time library<br />

must provide this language-independent functionality. End aside).<br />

This model is intended to be suitable <strong>for</strong> <strong>ARM</strong>'s C and C++ implementations as <strong>the</strong>y stand now and as <strong>the</strong>y are<br />

expected to develop in <strong>the</strong> <strong>for</strong>eseeable future, and also <strong>for</strong> third party implementations which adopt a similar, but<br />

not necessarily identical code generation strategy.<br />

The operations required to unwind a stack frame are encoded as a sequence of bytes:<br />

<br />

<br />

<br />

Unwinding operations that occur [statically] frequently are encoded relatively compactly.<br />

Unwinding operations that occur [statically] infrequently are catered <strong>for</strong>, but less compactly.<br />

Some operation codes are left unallocated, <strong>for</strong> future expansion.<br />

A single unwind description applies to <strong>the</strong> whole function. Thus it is required that <strong>the</strong> object code implementing a<br />

function can be partitioned into:<br />

<br />

<br />

<br />

An entry sequence, in which all register saving occurs and which cannot throw.<br />

One or more exit sequences, which restore registers and which cannot throw.<br />

Fragments which might throw.<br />

The encoding requires that at all points within a function body from which unwinding can start (that is, from each<br />

function call site), <strong>the</strong> addresses of saved registers are compile-time offsets from a fixed register chosen by <strong>the</strong><br />

compiler. Often this will be sp, but it may be an alternative frame pointer register. In o<strong>the</strong>r words, compilers have<br />

two choices.<br />

<br />

<br />

Do not adjust <strong>the</strong> stack pointer in <strong>the</strong> function body (only during entry and exit).<br />

Allocate a frame pointer register whose value is not changed in <strong>the</strong> function body.<br />

The choice can be made on a per-function basis.<br />

9.2 <strong>Exception</strong>-handling table entries<br />

An exception-handling table entry is a sequence of words and halfwords, beginning on a word boundary.<br />

The first word is as described in §6.3. The most significant byte encodes <strong>the</strong> index of <strong>the</strong> personality routine (PR)<br />

used to interpret what follows.<br />

0 Su16—Short frame unwinding description followed by descriptors with 16-bit scope.<br />

1 Lu16—Long frame unwinding description followed by descriptors with 16-bit scope.<br />

2 Lu32— Long frame unwinding description followed by descriptors with 32-bit scope.<br />

The corresponding personality routines are declared as:<br />

<strong>ARM</strong> IHI 0038A Copyright © 2002-2005, 2007 <strong>ARM</strong> Limited. All rights reserved. Page 38 of 50

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!