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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

11001yyy Spare (yyy != 000, 001)<br />

11010nnn<br />

11xxxyyy Spare (xxx != 000, 001, 010)<br />

Pop VFP double-precision registers D[8]-D[8+nnn] saved (as if) by FSTMFDD (see<br />

remark d)<br />

It may be possible <strong>for</strong> application code to save registers in a variety of data representations. When restoring<br />

registers <strong>the</strong> personality routine will assume that <strong>the</strong> application saved <strong>the</strong> registers using <strong>the</strong> following<br />

representations:<br />

<br />

<br />

<br />

<br />

An integer register is assumed to be on <strong>the</strong> stack as if transferred by a STR instruction.<br />

A sequence of VFP registers encoded in a single unwind instruction are assumed to have been saved as if by<br />

FSTMFDX or FSTMFDD, depending on <strong>the</strong> unwind instruction used.<br />

A WMMX data register is assumed to have been saved as if by WSTRD.<br />

A WMMX control register is assumed to have been saved as if by WSTRW.<br />

9.4 Interpreting <strong>the</strong> tables<br />

Recall that <strong>the</strong> return address into <strong>the</strong> current function is in VRS[r15] on entry to <strong>the</strong> personality routine. The<br />

personality routines interpret an exception-handling table entry as follows:<br />

The descriptors are traversed linearly.<br />

Cleanup descriptors are ignored in phase 1. In phase 2, if <strong>the</strong> return address is within <strong>the</strong> specified range, <strong>the</strong> PR<br />

must update <strong>the</strong> virtual register set <strong>for</strong> entry to <strong>the</strong> landing pad, call __cxa_begin_cleanup (see §8.4), save<br />

whatever it needs in <strong>the</strong> UCB cleanup_cache (see 7.2) <strong>the</strong>n return _URC_INSTALL_CONTEXT.<br />

Catch descriptors are examined in phase 1. If <strong>the</strong> return address is within <strong>the</strong> specified range, <strong>the</strong> type of <strong>the</strong><br />

thrown exception is checked <strong>for</strong> a match against <strong>the</strong> catch type. __cxa_type_match (see §8.4) may be used when<br />

offset encodes a type_info object. A match denotes a propagation barrier and <strong>the</strong> PR should fill in <strong>the</strong><br />

barrier_cache and return _URC_HANDLER_FOUND. On re-encountering <strong>the</strong> barrier in phase 2, <strong>the</strong> PR should<br />

set <strong>the</strong> VRS <strong>for</strong> landing pad entry (passing <strong>the</strong> UCB address in r0) and return _URC_INSTALL_CONTEXT.<br />

Function exception specification descriptors are examined in phase 1. If <strong>the</strong> return address is within <strong>the</strong> specified<br />

range, <strong>the</strong> type of <strong>the</strong> thrown exception is checked <strong>for</strong> a match against <strong>the</strong> specified types. __cxa_type_match<br />

(see §8.4) may be used. No match against any of <strong>the</strong> types denotes a propagation barrier and <strong>the</strong> PR should fill in<br />

<strong>the</strong> barrier_cache and return _URC_HANDLER_FOUND. On re-encountering <strong>the</strong> barrier in phase 2, <strong>the</strong><br />

behaviour depends on whe<strong>the</strong>r <strong>the</strong> descriptor has an explicitly specified landing pad (signified by high bit set in <strong>the</strong><br />

type count word) or not:<br />

<br />

<br />

If it does, <strong>the</strong> PR should set <strong>the</strong> VRS <strong>for</strong> entry to that pad (passing <strong>the</strong> UCB address in r0), ensure <strong>the</strong> data<br />

required <strong>for</strong> __cxa_call_unexpected is in <strong>the</strong> barrier_cache (see §8.2), and <strong>the</strong>n return<br />

_URC_INSTALL_CONTEXT. The pad will call __cxa_call_unexpected.<br />

If it does not, <strong>the</strong> PR should execute <strong>the</strong> unwind description to virtually unwind <strong>the</strong> frame, set <strong>the</strong> VRS <strong>for</strong><br />

entry to __cxa_call_unexpected (see §8.4), ensure <strong>the</strong> data required <strong>for</strong> __cxa_call_unexpected is in <strong>the</strong><br />

barrier_cache (see §8.2), <strong>the</strong>n return _URC_INSTALL_CONTEXT.<br />

If <strong>the</strong> PR has retained control after processing <strong>the</strong> final descriptor, it must execute <strong>the</strong> unwind description to<br />

virtually unwind <strong>the</strong> frame. It must <strong>the</strong>n return _URC_CONTINUE_UNWIND, causing <strong>the</strong> unwinder to locate and<br />

initiate processing of <strong>the</strong> next frame.<br />

The PR is not allowed to change its mind about a barrier between phase 1 and phase 2.<br />

In summary, <strong>the</strong> <strong>ARM</strong> personality routines always pass a pointer to <strong>the</strong> UCB in r0 when entering a handler or a<br />

handler landing pad.<br />

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

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

Saved successfully!

Ooh no, something went wrong!