pub struct ExceptionTableBuilder {
pub callsites: Vec<U32Bytes<LittleEndian>>,
pub ranges: Vec<U32Bytes<LittleEndian>>,
pub tags: Vec<U32Bytes<LittleEndian>>,
pub contexts: Vec<U32Bytes<LittleEndian>>,
pub handlers: Vec<U32Bytes<LittleEndian>>,
/* private fields */
}Expand description
Collector struct for exception handlers per call site.
§Format
We keep five different arrays (Vecs) that we build as we visit
callsites, in ascending offset (address relative to beginning of
code segment) order: callsite offsets, tag/destination ranges,
tags, tag context SP offset, destination offsets.
The callsite offsets and tag/destination ranges logically form a sorted lookup array, allowing us to find information for any single callsite. The range denotes a range of indices in the tag/context and destination offset arrays. Ranges are stored with the (exclusive) end index only; the start index is implicit as the previous end, or zero if first element.
The slices of tag, context, and handlers arrays named by ranges
for each callsite specify a series of handler items for that
callsite. The tag and context together allow a
dynamic-tag-instance match in the unwinder: the context specifies
an offset from SP at the callsite that contains a machine word
(e.g. with vmctx) that, together with the static tag index, can be
used to perform a dynamic match. A context of -1 indicates no
dynamic context, and a tag of -1 indicates a catch-all
handler. If a handler item matches, control should be transferred
to the code offset given in the last array, handlers.
§Example
An example of this data format:
callsites: [0x10, 0x50, 0xf0] // callsites (return addrs) at offsets 0x10, 0x50, 0xf0
ranges: [2, 4, 5] // corresponding ranges for each callsite
tags: [1, 5, 1, -1, -1] // tags for each handler at each callsite
contexts: [-1, -1, 0x10, 0x20, 0x30] // SP-offset for context for each tag
handlers: [0x40, 0x42, 0x6f, 0x71, 0xf5] // handler destinations at each callsiteExpanding this out:
callsites: [0x10, 0x50, 0xf0], # PCs relative to some start of return-points.
ranges: [
2, # callsite 0x10 has tags/handlers indices 0..2
4, # callsite 0x50 has tags/handlers indices 2..4
5, # callsite 0xf0 has tags/handlers indices 4..5
],
tags: [
# tags for callsite 0x10:
1,
5,
# tags for callsite 0x50:
1,
-1, # "catch-all"
# tags for callsite 0xf0:
-1, # "catch-all"
]
contexts: [
# SP-offsets for context for each tag at callsite 0x10:
-1,
-1,
# for callsite 0x50:
0x10,
0x20,
# for callsite 0xf0:
0x30,
]
handlers: [
# handlers for callsite 0x10:
0x40, # relative PC to handle tag 1 (above)
0x42, # relative PC to handle tag 5
# handlers for callsite 0x50:
0x6f, # relative PC to handle tag 1
0x71, # relative PC to handle all other tags
# handlers for callsite 0xf0:
0xf5, # relative PC to handle all other tags
]Fields§
§callsites: Vec<U32Bytes<LittleEndian>>§ranges: Vec<U32Bytes<LittleEndian>>§contexts: Vec<U32Bytes<LittleEndian>>§handlers: Vec<U32Bytes<LittleEndian>>Implementations§
Source§impl ExceptionTableBuilder
impl ExceptionTableBuilder
Sourcepub fn add_func<'a>(
&mut self,
start_offset: CodeOffset,
call_sites: impl Iterator<Item = FinalizedMachCallSite<'a>>,
) -> Result<()>
pub fn add_func<'a>( &mut self, start_offset: CodeOffset, call_sites: impl Iterator<Item = FinalizedMachCallSite<'a>>, ) -> Result<()>
Add a function at a given offset from the start of the compiled code section, recording information about its call sites.
Functions must be added in ascending offset order.
Trait Implementations§
Source§impl Clone for ExceptionTableBuilder
impl Clone for ExceptionTableBuilder
Source§fn clone(&self) -> ExceptionTableBuilder
fn clone(&self) -> ExceptionTableBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more