[Devel] [PATCH hci-8.1 08/14] ms/objtool: Fix data alignment in elf_add_data()

Konstantin Khorenko khorenko at virtuozzo.com
Thu Nov 26 17:30:21 MSK 2026


From: Josh Poimboeuf <jpoimboe at kernel.org>

Any data added to a section needs to be aligned in accordance with the
section's sh_addralign value.  Particularly strings added to a .str1.8
section.  Otherwise you may get some funky strings.

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Link: https://patch.msgid.link/d962fc0ca24fa0825cca8dad71932dccdd9312a9.1772681234.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe at kernel.org>
(cherry picked from commit 356e4b2f5b80f757965f3f4d0219c81fca91b6f2)

https://virtuozzo.atlassian.net/browse/VSTOR-157133
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 tools/objtool/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index bc1ca8e439c9a..da20cec49374b 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -1351,7 +1351,7 @@ void *elf_add_data(struct elf *elf, struct section *sec, const void *data, size_
 		memcpy(sec->data->d_buf, data, size);
 
 	sec->data->d_size = size;
-	sec->data->d_align = 1;
+	sec->data->d_align = sec->sh.sh_addralign;
 
 	offset = ALIGN_UP(sec->sh.sh_size, sec->sh.sh_addralign);
 	sec->sh.sh_size = offset + size;

-- 
2.43.0



More information about the Devel mailing list