MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / parse_address_map

Function parse_address_map

crates/environ/src/address_map.rs:146–158  ·  view source on GitHub ↗

Parse an `ELF_WASMTIME_ADDRMAP` section, returning the slice of code offsets and the slice of associated file positions for each offset.

(section: &[u8])

Source from the content-addressed store, hash-verified

144/// Parse an `ELF_WASMTIME_ADDRMAP` section, returning the slice of code offsets
145/// and the slice of associated file positions for each offset.
146fn parse_address_map(section: &[u8]) -> Option<(&[U32<LittleEndian>], &[U32<LittleEndian>])> {
147 let mut section = Bytes(section);
148 // NB: this matches the encoding written by `append_to` in the
149 // `compile::address_map` module.
150 let count = section.read::<U32<LittleEndian>>().ok()?;
151 let count = usize::try_from(count.get(LittleEndian)).ok()?;
152 let (offsets, section) =
153 object::slice_from_bytes::<U32<LittleEndian>>(section.0, count).ok()?;
154 let (positions, section) =
155 object::slice_from_bytes::<U32<LittleEndian>>(section, count).ok()?;
156 debug_assert!(section.is_empty());
157 Some((offsets, positions))
158}
159
160/// Lookup an `offset` within an encoded address map section, returning the
161/// original `FilePos` that corresponds to the offset, if found.

Callers 2

lookup_file_posFunction · 0.85
iterate_address_mapFunction · 0.85

Calls 2

okMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected