[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250127114334.1045857-5-ardb+git@google.com>
Date: Mon, 27 Jan 2025 12:43:36 +0100
From: Ard Biesheuvel <ardb+git@...gle.com>
To: linux-kernel@...r.kernel.org
Cc: x86@...nel.org, Ard Biesheuvel <ardb@...nel.org>, Ingo Molnar <mingo@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>, Tom Lendacky <thomas.lendacky@....com>,
Nathan Chancellor <nathan@...nel.org>
Subject: [RFC PATCH 1/2] x86/relocs: Improve diagnostic for rejected absolute references
From: Ard Biesheuvel <ardb@...nel.org>
Compiler emitted absolute references are often section-relative, as the
objects in question sometimes don't even exist in the C code (e.g., jump
tables) or have static linkage.
Enhance the diagnostic that is printed when detecting absolute
references in .head.text, but printing the addend of the symbol
reference, and the location in vmlinux where the reference can be found.
So instead of printing
Absolute reference to symbol '.rodata' detected not permitted in .head.text
and failing the build, print the below but only as a warning.
Absolute reference to symbol '.rodata+0x180' detected in .head.text (0xffffffff820cb4ba).
This kernel may might not boot.
Not failing the build also works around the issue that the file vmlinux
will be deleted by make when an error occurs, which is not very helpful
in trying to narrow down the problem.
Reported-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Ard Biesheuvel <ardb@...nel.org>
---
arch/x86/tools/relocs.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index e937be979ec8..134cf5cfe7bd 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -901,9 +901,10 @@ static int do_reloc64(struct section *sec, Elf_Rel *rel, ElfW(Sym) *sym,
}
if (headtext) {
- die("Absolute reference to symbol '%s' not permitted in .head.text\n",
- symname);
- break;
+ fprintf(stderr,
+ "Absolute reference to symbol '%s+0x%lx' detected in .head.text (0x%lx).\n"
+ "This kernel might not boot.\n",
+ symname, rel->r_addend, offset);
}
/*
--
2.48.1.262.g85cc9f2d1e-goog
Powered by blists - more mailing lists