mirror of
https://github.com/encounter/objdiff.git
synced 2025-07-03 11:45:57 +00:00
Fallback to mapping symbol $a
This commit is contained in:
parent
7733459715
commit
2d06abec19
@ -1,6 +1,6 @@
|
|||||||
use std::{borrow::Cow, collections::HashMap};
|
use std::{borrow::Cow, collections::HashMap};
|
||||||
|
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Result};
|
||||||
use armv5te::{arm, thumb};
|
use armv5te::{arm, thumb};
|
||||||
use object::{
|
use object::{
|
||||||
elf, File, Object, ObjectSection, ObjectSymbol, Relocation, RelocationFlags, SectionIndex,
|
elf, File, Object, ObjectSection, ObjectSymbol, Relocation, RelocationFlags, SectionIndex,
|
||||||
@ -58,18 +58,18 @@ impl ObjArch for ObjArchArm {
|
|||||||
let end_addr = start_addr + symbol.size as u32;
|
let end_addr = start_addr + symbol.size as u32;
|
||||||
|
|
||||||
// Mapping symbols decide what kind of data comes after it. $a for ARM code, $t for Thumb code and $d for data.
|
// Mapping symbols decide what kind of data comes after it. $a for ARM code, $t for Thumb code and $d for data.
|
||||||
|
let fallback_mappings =
|
||||||
|
[DisasmMode { address: symbol.address as u32, mapping: MappingSymbol::Arm }];
|
||||||
let mapping_symbols = self
|
let mapping_symbols = self
|
||||||
.disasm_modes
|
.disasm_modes
|
||||||
.get(&SectionIndex(section.orig_index))
|
.get(&SectionIndex(section.orig_index))
|
||||||
.with_context(|| format!("No mappings symbols in the section of '{}'", symbol.name))?;
|
.map(|x| x.as_slice())
|
||||||
let first_mapping = self
|
.unwrap_or(&fallback_mappings);
|
||||||
.disasm_modes
|
let first_mapping =
|
||||||
.get(&SectionIndex(section.orig_index))
|
match mapping_symbols.binary_search_by_key(&(symbol.address as u32), |x| x.address) {
|
||||||
.map(|s| match s.binary_search_by_key(&(symbol.address as u32), |x| x.address) {
|
|
||||||
Ok(idx) => idx,
|
Ok(idx) => idx,
|
||||||
Err(idx) => idx - 1,
|
Err(idx) => idx - 1,
|
||||||
})
|
};
|
||||||
.with_context(|| format!("No mapping symbol found before or at '{}'", symbol.name))?;
|
|
||||||
let mut mapping = mapping_symbols[first_mapping].mapping;
|
let mut mapping = mapping_symbols[first_mapping].mapping;
|
||||||
|
|
||||||
let mut mappings_iter =
|
let mut mappings_iter =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user