Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Platform:Itanium C++ ABI/LSDA

From ReverseEngineering.wiki

Layout of the language-specific data area (LSDA) in .gcc_except_table that the Itanium personality routines (__gxx_personality_v0, Rust's rust_eh_personality) read: header encodings, call-site table, action table and type table, plus the DW_EH_PE pointer encodings.

Where it is

Each function that has landing pads (cleanups, catch clauses) has a record in .gcc_except_table (ELF; __gcc_except_tab on Mach-O). The function's FDE in .eh_frame carries the augmentation data L whose value is a pointer to this record, and the CIE names the personality routine (P). The unwinder passes the LSDA pointer and the throwing IP to the personality routine, which finds the call site containing the IP. In a stripped binary the personality symbol (__gxx_personality_v0, __gcc_personality_v0, rust_eh_personality, __gxx_personality_sj0) is usually still imported; every FDE using it points at an LSDA.

Layout

Field Encoding Meaning
lpstart_encoding u8 DW_EH_PE format of the next field; 0xFF (omit) means landing pads are relative to the function start
lpstart per encoding present only if the encoding is not omit: base for landing pad offsets
ttype_encoding u8 format of type-table entries; 0xFF = no type table
ttype_offset ULEB128 present only if ttype_encoding != 0xFF: offset from here to the end of the type table (the table is read backwards from there)
call_site_encoding u8 format of the call-site fields
call_site_table_length ULEB128 byte length of the call-site table; the action table follows it directly
call-site records repeated cs_start, cs_len, cs_lpad (all in call_site_encoding; start relative to the function start, lpad relative to lpstart) then cs_action (ULEB128)
action table records ttype_index (SLEB128), next (SLEB128, byte displacement to the next record, 0 = last)
type table ttype_encoding entries type_info pointers, indexed backwards from the table end (index 1 is the last entry before the end)

Semantics: call-site records are sorted by cs_start; the record with cs_start <= IP - func_start < cs_start + cs_len applies. cs_lpad == 0 means no landing pad. An IP not covered by any record means the call may not throw and the personality terminates the program. cs_action == 0 is a pure cleanup (destructors); otherwise cs_action - 1 is a byte offset into the action table. For an action record: ttype_index > 0 is a catch clause for the type at type_table[-ttype_index] (a null entry is catch (...)), ttype_index == 0 is a cleanup, ttype_index < 0 is an exception specification (filter). Records chained by next are tried in order.

DW_EH_PE pointer encodings

One byte: the low nibble is the format, the high bits the base.

Value Meaning Value Meaning
0x00 absptr pointer-sized 0x10 pcrel relative to the address of the field
0x01 uleb128 0x20 textrel relative to the text base
0x02 udata2 0x30 datarel relative to the data base
0x03 udata4 0x40 funcrel relative to the function start
0x04 udata8 0x50 aligned aligned pointer
0x09 sleb128 0x80 indirect the value is the address of the pointer
0x0A sdata2, 0x0B sdata4, 0x0C sdata8 0xFF omit absent

A value of 0x9B is indirect + pcrel + sdata4: each type-table entry is a 4-byte offset to a cell holding the type_info address (typical for PIE and shared objects). Unverified: which encodings GCC and LLVM pick per target; read the encoding bytes of the file at hand.

Using it in reverse engineering

  • The type table lists which exception classes a function catches (_ZTI... addresses, see Platform:Itanium C++ ABI/RTTI and vtables).
  • Call-site ranges delimit try regions; landing-pad addresses are the catch and cleanup blocks that no jump references, so seed them as code entry points.
  • 32-bit ARM unwinds with .ARM.exidx/.ARM.extab (EHABI) but uses the same LSDA for the language-specific part (Unverified for every ARM toolchain); SjLj targets use a call-site index instead of an address range and the table holds only ULEB128 pairs (landing pad, action).

Reference implementation

Rust's standard library carries a short readable LSDA parser (find_eh_action in library/std/src/sys/personality/dwarf/eh.rs), following GCC's libgcc/unwind-c.c; it ignores the type table because Rust does not match exception types. See Tool:rustc.

Evidence & references

  • rust-lang/rust 02fb0a16311c3411fa373627706da085cd8fbd3c library/std/src/sys/personality/dwarf/eh.rs lines 1-200 (header, encodings 19-40, call-site and action table 77-195, SjLj 134-156).
  • Itanium C++ ABI exception handling document (https://itanium-cxx-abi.github.io/cxx-abi/exceptions.pdf) and LSB, cited by that file's header.