MCPcopy Create free account
hub / github.com/Rust-for-Linux/klint / decode

Method decode

src/binary_analysis/dwarf.rs:131–145  ·  view source on GitHub ↗
(&self, address: u64)

Source from the content-addressed store, hash-verified

129 }
130
131 fn decode(&self, address: u64) -> Result<(SectionIndex, i64), Error> {
132 let address_plus_gap = address
133 .checked_add(Self::SECTION_GAP / 2)
134 .ok_or(Error::UnexpectedElf("unexpected symbol offset"))?;
135 let Some((&section_start, &index)) = self.reverse_map.range(..address_plus_gap).next_back()
136 else {
137 Err(Error::UnexpectedElf(
138 "address from unallocated section cannot be decoded",
139 ))?
140 };
141
142 let offset = (address as i64).wrapping_sub(section_start as _);
143 assert_eq!(self.encode(SectionIndex(index), offset).unwrap(), address);
144 Ok((SectionIndex(index), offset))
145 }
146}
147
148fn load_section<'file, 'data>(

Callers 2

rangesMethod · 0.80
locateMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected