summaryrefslogtreecommitdiff
path: root/tools/objtool/arch/x86/decode.c
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2025-09-17 09:03:29 -0700
committerJosh Poimboeuf <jpoimboe@kernel.org>2025-10-14 14:45:24 -0700
commit68245893cf447cca478e6bd71c02741656053ef4 (patch)
tree2a30c2b28be64e015bc835359125152e06f0840c /tools/objtool/arch/x86/decode.c
parent41d24d78589705f85cbe90e5a8c1b55ea05557a2 (diff)
objtool: Fix __pa_symbol() relocation handling
__pa_symbol() generates a relocation which refers to a physical address. Convert it to back its virtual form before calculating the addend. Acked-by: Petr Mladek <pmladek@suse.com> Tested-by: Joe Lawrence <joe.lawrence@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Diffstat (limited to 'tools/objtool/arch/x86/decode.c')
-rw-r--r--tools/objtool/arch/x86/decode.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index 6742002a01f5..b10200cc50c9 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -68,6 +68,17 @@ bool arch_callee_saved_reg(unsigned char reg)
}
}
+/* Undo the effects of __pa_symbol() if necessary */
+static unsigned long phys_to_virt(unsigned long pa)
+{
+ s64 va = pa;
+
+ if (va > 0)
+ va &= ~(0x80000000);
+
+ return va;
+}
+
s64 arch_insn_adjusted_addend(struct instruction *insn, struct reloc *reloc)
{
s64 addend = reloc_addend(reloc);
@@ -75,7 +86,7 @@ s64 arch_insn_adjusted_addend(struct instruction *insn, struct reloc *reloc)
if (arch_pc_relative_reloc(reloc))
addend += insn->offset + insn->len - reloc_offset(reloc);
- return addend;
+ return phys_to_virt(addend);
}
unsigned long arch_jump_destination(struct instruction *insn)