Skip to content

Commit dc02368

Browse files
joe-lawrencejpoimboe
authored andcommitted
objtool: Make .altinstructions section entry size consistent
Commit e31694e ("objtool: Don't make .altinstructions writable") aligned objtool-created and kernel-created .altinstructions section flags, but there remains a minor discrepency in their use of a section entry size: objtool sets one while the kernel build does not. While sh_entsize of sizeof(struct alt_instr) seems intuitive, this small deviation can cause failures with external tooling (kpatch-build). Fix this by creating new .altinstructions sections with sh_entsize of 0 and then later updating sec->sh_size as alternatives are added to the section. An added benefit is avoiding the data descriptor and buffer created by elf_create_section(), but previously unused by elf_add_alternative(). Fixes: 9bc0bb5 ("objtool/x86: Rewrite retpoline thunk calls") Signed-off-by: Joe Lawrence <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: Andy Lavr <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Cc: [email protected]
1 parent 4d8b359 commit dc02368

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/objtool/arch/x86/decode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ static int elf_add_alternative(struct elf *elf,
684684
sec = find_section_by_name(elf, ".altinstructions");
685685
if (!sec) {
686686
sec = elf_create_section(elf, ".altinstructions",
687-
SHF_ALLOC, size, 0);
687+
SHF_ALLOC, 0, 0);
688688

689689
if (!sec) {
690690
WARN_ELF("elf_create_section");

0 commit comments

Comments
 (0)