mirror of
https://github.com/encounter/objdiff.git
synced 2026-07-10 12:18:36 -07:00
Add support for R_ARM_V4BX (#377)
This commit is contained in:
@@ -343,6 +343,15 @@ impl Arch for ArchArm {
|
||||
// Handle ELF implicit relocations
|
||||
object::RelocationFlags::Elf { r_type } => {
|
||||
if relocation.has_implicit_addend() {
|
||||
// R_ARM_V4BX marks a `bx` instruction so the linker can optionally
|
||||
// rewrite it for ARMv4 interworking. Drops the addend since it's meaningless.
|
||||
if r_type == elf::R_ARM_V4BX {
|
||||
return Ok(Some(RelocationOverride {
|
||||
target: RelocationOverrideTarget::Skip,
|
||||
addend: 0,
|
||||
}));
|
||||
}
|
||||
|
||||
let section_data = section.data()?;
|
||||
let address = address as usize;
|
||||
let addend = match r_type {
|
||||
@@ -419,6 +428,7 @@ impl Arch for ArchArm {
|
||||
elf::R_ARM_CALL => Some("R_ARM_CALL"),
|
||||
elf::R_ARM_THM_PC11 => Some("R_ARM_THM_PC11"),
|
||||
elf::R_ARM_THM_PC9 => Some("R_ARM_THM_PC9"),
|
||||
elf::R_ARM_V4BX => Some("R_ARM_V4BX"),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
|
||||
@@ -82,6 +82,22 @@ fn thumb_short_data_mapping() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "arm")]
|
||||
fn read_arm_v4bx() {
|
||||
// R_ARM_V4BX relocations mark `bx` instructions so the linker can optionally
|
||||
// rewrite them for ARMv4 interworking.
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj =
|
||||
obj::read::parse(include_object!("data/arm/v4bx.o"), &diff_config, diff::DiffSide::Base)
|
||||
.unwrap();
|
||||
let symbol_idx = obj.symbols.iter().position(|s| s.name == "v4bx_func").unwrap();
|
||||
let diff = diff::code::no_diff_code(&obj, symbol_idx, &diff_config).unwrap();
|
||||
let output = common::display_diff(&obj, &diff, symbol_idx, &diff_config);
|
||||
// The `bx lr` still disassembles normally; the V4BX hint is simply dropped.
|
||||
assert!(output.contains("bx"), "expected a `bx` instruction, got:\n{output}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "arm")]
|
||||
fn trim_trailing_hword() {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user