mirror of
https://github.com/encounter/objdiff.git
synced 2025-08-03 18:55:43 +00:00
Fix reading IMAGE_REL_PPC_REFHI/REFLO without PAIR
This commit is contained in:
parent
f5d3d5f10a
commit
dd653329f5
@ -462,6 +462,7 @@ impl Arch for ArchDummy {
|
||||
fn data_reloc_size(&self, _flags: RelocationFlags) -> usize { 0 }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum RelocationOverrideTarget {
|
||||
Keep,
|
||||
Skip,
|
||||
@ -469,6 +470,7 @@ pub enum RelocationOverrideTarget {
|
||||
Section(object::SectionIndex),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct RelocationOverride {
|
||||
pub target: RelocationOverrideTarget,
|
||||
pub addend: i64,
|
||||
|
@ -229,13 +229,19 @@ impl Arch for ArchPpc {
|
||||
typ: pe::IMAGE_REL_PPC_PAIR
|
||||
})
|
||||
})
|
||||
.map_or(Ok(None), |(_, reloc)| match reloc.target() {
|
||||
object::RelocationTarget::Symbol(index) => Ok(Some(RelocationOverride {
|
||||
.map_or(
|
||||
Ok(Some(RelocationOverride {
|
||||
target: RelocationOverrideTarget::Keep,
|
||||
addend: index.0 as u16 as i16 as i64,
|
||||
addend: 0,
|
||||
})),
|
||||
target => Err(anyhow!("Unsupported IMAGE_REL_PPC_PAIR target {target:?}")),
|
||||
}),
|
||||
|(_, reloc)| match reloc.target() {
|
||||
object::RelocationTarget::Symbol(index) => Ok(Some(RelocationOverride {
|
||||
target: RelocationOverrideTarget::Keep,
|
||||
addend: index.0 as u16 as i16 as i64,
|
||||
})),
|
||||
target => Err(anyhow!("Unsupported IMAGE_REL_PPC_PAIR target {target:?}")),
|
||||
},
|
||||
),
|
||||
// Skip PAIR relocations as they are handled by the previous case
|
||||
object::RelocationFlags::Coff { typ: pe::IMAGE_REL_PPC_PAIR } => {
|
||||
Ok(Some(RelocationOverride { target: RelocationOverrideTarget::Skip, addend: 0 }))
|
||||
|
@ -361,7 +361,8 @@ fn map_section_relocations(
|
||||
None => {
|
||||
ensure!(
|
||||
!reloc.has_implicit_addend(),
|
||||
"Unsupported implicit relocation {:?}",
|
||||
"Unsupported {:?} implicit relocation {:?}",
|
||||
obj_file.architecture(),
|
||||
reloc.flags()
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user