summaryrefslogtreecommitdiff
path: root/tools/objtool/arch
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2025-08-28 12:22:18 +0200
committerBorislav Petkov (AMD) <bp@alien8.de>2025-09-03 17:59:51 +0200
commit0d6e4563fc03d83f948e6a6f7963cc31a4c81914 (patch)
treebc24f8f840d956dc73d1ac740207432f929256f1 /tools/objtool/arch
parent05ce314ba5155d57c86f8f276cb17f78ac5fb4f0 (diff)
objtool: Add action to check for absence of absolute relocations
The x86 startup code must not use absolute references to code or data, as it executes before the kernel virtual mapping is up. Add an action to objtool to check all allocatable sections (with the exception of __patchable_function_entries, which uses absolute references for nebulous reasons) and raise an error if any absolute references are found. Note that debug sections typically contain lots of absolute references too, but those are not allocatable so they will be ignored. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/20250828102202.1849035-39-ardb+git@google.com
Diffstat (limited to 'tools/objtool/arch')
-rw-r--r--tools/objtool/arch/x86/decode.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index 98c4713c1b09..0ad5cc70ecbe 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -880,3 +880,15 @@ unsigned int arch_reloc_size(struct reloc *reloc)
return 8;
}
}
+
+bool arch_absolute_reloc(struct elf *elf, struct reloc *reloc)
+{
+ switch (reloc_type(reloc)) {
+ case R_X86_64_32:
+ case R_X86_64_32S:
+ case R_X86_64_64:
+ return true;
+ default:
+ return false;
+ }
+}