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 }
|
fn data_reloc_size(&self, _flags: RelocationFlags) -> usize { 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum RelocationOverrideTarget {
|
pub enum RelocationOverrideTarget {
|
||||||
Keep,
|
Keep,
|
||||||
Skip,
|
Skip,
|
||||||
@ -469,6 +470,7 @@ pub enum RelocationOverrideTarget {
|
|||||||
Section(object::SectionIndex),
|
Section(object::SectionIndex),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct RelocationOverride {
|
pub struct RelocationOverride {
|
||||||
pub target: RelocationOverrideTarget,
|
pub target: RelocationOverrideTarget,
|
||||||
pub addend: i64,
|
pub addend: i64,
|
||||||
|
@ -229,13 +229,19 @@ impl Arch for ArchPpc {
|
|||||||
typ: pe::IMAGE_REL_PPC_PAIR
|
typ: pe::IMAGE_REL_PPC_PAIR
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.map_or(Ok(None), |(_, reloc)| match reloc.target() {
|
.map_or(
|
||||||
object::RelocationTarget::Symbol(index) => Ok(Some(RelocationOverride {
|
Ok(Some(RelocationOverride {
|
||||||
target: RelocationOverrideTarget::Keep,
|
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
|
// Skip PAIR relocations as they are handled by the previous case
|
||||||
object::RelocationFlags::Coff { typ: pe::IMAGE_REL_PPC_PAIR } => {
|
object::RelocationFlags::Coff { typ: pe::IMAGE_REL_PPC_PAIR } => {
|
||||||
Ok(Some(RelocationOverride { target: RelocationOverrideTarget::Skip, addend: 0 }))
|
Ok(Some(RelocationOverride { target: RelocationOverrideTarget::Skip, addend: 0 }))
|
||||||
|
@ -361,7 +361,8 @@ fn map_section_relocations(
|
|||||||
None => {
|
None => {
|
||||||
ensure!(
|
ensure!(
|
||||||
!reloc.has_implicit_addend(),
|
!reloc.has_implicit_addend(),
|
||||||
"Unsupported implicit relocation {:?}",
|
"Unsupported {:?} implicit relocation {:?}",
|
||||||
|
obj_file.architecture(),
|
||||||
reloc.flags()
|
reloc.flags()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user