]> git.baikalelectronics.ru Git - kernel.git/commit
objtool: Make .altinstructions section entry size consistent
authorJoe Lawrence <joe.lawrence@redhat.com>
Sun, 22 Aug 2021 22:50:36 +0000 (18:50 -0400)
committerJosh Poimboeuf <jpoimboe@redhat.com>
Tue, 5 Oct 2021 19:03:20 +0000 (12:03 -0700)
commitb8cadd615d7427b453b0e33440a09fde498e11e1
tree37bdf201a6df6c0818324c3985a587d22eb5b20d
parente053b80f5c4296d4cf0e2c30af26d3d62ea9815b
objtool: Make .altinstructions section entry size consistent

Commit 97a0ee78ea48 ("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: db8e6c9e5e72 ("objtool/x86: Rewrite retpoline thunk calls")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20210822225037.54620-2-joe.lawrence@redhat.com
Cc: Andy Lavr <andy.lavr@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
tools/objtool/arch/x86/decode.c