From 507b988aa33b7acb391d24b1c69ad63d68a7d17d Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 2 Dec 2024 18:05:32 -0500 Subject: [PATCH] Clear pool relocs in volatile registers on function call This fixes some false positives. --- objdiff-core/src/arch/ppc.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/objdiff-core/src/arch/ppc.rs b/objdiff-core/src/arch/ppc.rs index be84122..a14852a 100644 --- a/objdiff-core/src/arch/ppc.rs +++ b/objdiff-core/src/arch/ppc.rs @@ -520,6 +520,16 @@ fn generate_fake_pool_reloc_for_addr_mapping( ) => { active_pool_relocs.insert(addr_dst_gpr.0, reloc.clone()); // `lis` + `ori` } + (Opcode::B, _, _, _) => { + if simplified.mnemonic == "bl" { + // When encountering a function call, clear any active pool relocations from + // the volatile registers (r0, r3-r12), but not the nonvolatile registers. + active_pool_relocs.remove(&0); + for gpr in 3..12 { + active_pool_relocs.remove(&gpr); + } + } + } _ => {} } } else if let Some((offset, addr_src_gpr, addr_dst_gpr)) =