| 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((§ion_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 | |
| 148 | fn load_section<'file, 'data>( |