| 312 | |
| 313 | impl Object { |
| 314 | pub fn resolve_instruction_ref( |
| 315 | &self, |
| 316 | symbol_index: usize, |
| 317 | ins_ref: InstructionRef, |
| 318 | ) -> Option<ResolvedInstructionRef<'_>> { |
| 319 | let symbol = self.symbols.get(symbol_index)?; |
| 320 | let section_index = symbol.section?; |
| 321 | let section = self.sections.get(section_index)?; |
| 322 | let offset = ins_ref.address.checked_sub(section.address)?; |
| 323 | let code = section.data.get(offset as usize..offset as usize + ins_ref.size as usize)?; |
| 324 | let relocation = section.resolve_relocation_at(self, ins_ref.address, ins_ref.size); |
| 325 | Some(ResolvedInstructionRef { |
| 326 | ins_ref, |
| 327 | symbol_index, |
| 328 | symbol, |
| 329 | section, |
| 330 | section_index, |
| 331 | code, |
| 332 | relocation, |
| 333 | }) |
| 334 | } |
| 335 | |
| 336 | pub fn symbol_data(&self, symbol_index: usize) -> Option<&[u8]> { |
| 337 | let symbol = self.symbols.get(symbol_index)?; |