Parse an `ELF_WASMTIME_ADDRMAP` section, returning the slice of code offsets and the slice of associated file positions for each offset.
(section: &[u8])
| 144 | /// Parse an `ELF_WASMTIME_ADDRMAP` section, returning the slice of code offsets |
| 145 | /// and the slice of associated file positions for each offset. |
| 146 | fn 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. |
no test coverage detected