[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260209084820.57298-3-sv@linux.ibm.com>
Date: Mon, 9 Feb 2026 14:18:16 +0530
From: Sathvika Vasireddy <sv@...ux.ibm.com>
To: linux-kernel@...r.kernel.org, linux-kbuild@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org
Cc: nathan@...nel.org, masahiroy@...nel.org, kees@...nel.org,
naveen@...nel.org, jpoimboe@...nel.org, peterz@...radead.org,
npiggin@...il.com, maddy@...ux.ibm.com, segher@...nel.crashing.org,
christophe.leroy@...roup.eu, mingo@...nel.org, mpe@...erman.id.au,
sv@...ux.ibm.com, nsc@...nel.org
Subject: [RFC PATCH v3 2/6] objtool: Set ELF_F_LAYOUT flag to preserve vmlinux segment layout
When objtool writes changes back to vmlinux with --ftr-fixup --link,
libelf recalculates the file layout and inserts padding between
sections. This corrupts the ELF segment structure, causing kexec to
fail with:
ELF Note corrupted !
Cannot determine the file type of vmlinux
This happens because libelf's default behavior assumes it can freely
rearrange section offsets when writing, which breaks the carefully
constructed vmlinux layout produced by the linker.
Set ELF_F_LAYOUT after elf_begin() to instruct libelf that the
application is responsible for the file layout. This prevents libelf
from inserting padding or repositioning sections while still allowing
data modifications to be written back.
Signed-off-by: Sathvika Vasireddy <sv@...ux.ibm.com>
---
tools/objtool/elf.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 94370a470cbb..f7c6fd68ffcb 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -1159,6 +1159,9 @@ struct elf *elf_open_read(const char *name, int flags)
elf->elf = elf_begin(elf->fd, cmd, NULL);
+ if (opts.ftr_fixup)
+ elf_flagelf(elf->elf, ELF_C_SET, ELF_F_LAYOUT);
+
if (!elf->elf) {
ERROR_ELF("elf_begin");
goto err;
--
2.43.0
Powered by blists - more mailing lists