Skip to content

Commit 2f2600d

Browse files
joe-lawrencejpoimboe
authored andcommitted
objtool/klp: fix data alignment in __clone_symbol()
Commit 356e4b2 ("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: dd590d4 ("objtool/klp: Introduce klp diff subcommand for diffing object files") Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com> Link: https://patch.msgid.link/20260310203751.1479229-2-joe.lawrence@redhat.com Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
1 parent f338e77 commit 2f2600d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tools/objtool/klp-diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <objtool/util.h>
1515
#include <arch/special.h>
1616

17+
#include <linux/align.h>
1718
#include <linux/objtool_types.h>
1819
#include <linux/livepatch_external.h>
1920
#include <linux/stringify.h>
@@ -560,7 +561,7 @@ static struct symbol *__clone_symbol(struct elf *elf, struct symbol *patched_sym
560561
}
561562

562563
if (!is_sec_sym(patched_sym))
563-
offset = sec_size(out_sec);
564+
offset = ALIGN(sec_size(out_sec), out_sec->sh.sh_addralign);
564565

565566
if (patched_sym->len || is_sec_sym(patched_sym)) {
566567
void *data = NULL;

0 commit comments

Comments
 (0)