Commit 2f2600de authored by Joe Lawrence's avatar Joe Lawrence Committed by Josh Poimboeuf
Browse files

objtool/klp: fix data alignment in __clone_symbol()



Commit 356e4b2f ("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: dd590d4d ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Signed-off-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
Link: https://patch.msgid.link/20260310203751.1479229-2-joe.lawrence@redhat.com


Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
parent f338e773
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;