pub struct ExceptionTableBuilder {
pub callsites: Vec<U32Bytes<LittleEndian>>,
pub ranges: Vec<U32Bytes<LittleEndian>>,
pub tags: Vec<U32Bytes<LittleEndian>>,
pub handlers: Vec<U32Bytes<LittleEndian>>,
/* private fields */
}Expand description
Collector struct for exception handlers per call site.
§Format
We keep four different arrays (Vecs) that we build as we visit
callsites, in ascending offset (address relative to beginning of
code segment) order: tags, destination offsets, callsite offsets,
and tag/destination ranges.
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 and destination offset arrays, and those are sorted by tag per callsite. Ranges are stored with the (exclusive) end index only; the start index is implicit as the previous end, or zero if first element.
§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
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"
]
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>>§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