[tip: objtool/urgent] objtool/klp: fix data alignment in __clone_symbol()
From: tip-bot2 for Joe Lawrence
Date: Wed Mar 18 2026 - 04:31:25 EST
The following commit has been merged into the objtool/urgent branch of tip:
Commit-ID: 2f2600decb3004938762a3f2d0eba3ea9e01045b
Gitweb: https://git.kernel.org/tip/2f2600decb3004938762a3f2d0eba3ea9e01045b
Author: Joe Lawrence <joe.lawrence@xxxxxxxxxx>
AuthorDate: Tue, 10 Mar 2026 16:37:40 -04:00
Committer: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
CommitterDate: Mon, 16 Mar 2026 12:39:45 -07:00
objtool/klp: fix data alignment in __clone_symbol()
Commit 356e4b2f5b80 ("objtool: Fix data alignment in elf_add_data()")
corrected the alignment of data within a section (honoring the section's
sh_addralign). Apply the same alignment when klp-diff mode clones a
symbol, adjusting the new symbol's offset for the output section's
sh_addralign.
Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Signed-off-by: Joe Lawrence <joe.lawrence@xxxxxxxxxx>
Link: https://patch.msgid.link/20260310203751.1479229-2-joe.lawrence@xxxxxxxxxx
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
tools/objtool/klp-diff.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index a3198a6..c2c4e49 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -14,6 +14,7 @@
#include <objtool/util.h>
#include <arch/special.h>
+#include <linux/align.h>
#include <linux/objtool_types.h>
#include <linux/livepatch_external.h>
#include <linux/stringify.h>
@@ -560,7 +561,7 @@ static struct symbol *__clone_symbol(struct elf *elf, struct symbol *patched_sym
}
if (!is_sec_sym(patched_sym))
- offset = sec_size(out_sec);
+ offset = ALIGN(sec_size(out_sec), out_sec->sh.sh_addralign);
if (patched_sym->len || is_sec_sym(patched_sym)) {
void *data = NULL;