kernel_optimize_test/tools/objtool
Peter Zijlstra a031925382 objtool: Fix .symtab_shndx handling for elf_create_undef_symbol()
commit 584fd3b31889852d0d6f3dd1e3d8e9619b660d2c upstream.

When an ELF object uses extended symbol section indexes (IOW it has a
.symtab_shndx section), these must be kept in sync with the regular
symbol table (.symtab).

So for every new symbol we emit, make sure to also emit a
.symtab_shndx value to keep the arrays of equal size.

Note: since we're writing an UNDEF symbol, most GElf_Sym fields will
be 0 and we can repurpose one (st_size) to host the 0 for the xshndx
value.

Fixes: 2f2f7e47f052 ("objtool: Add elf_create_undef_symbol()")
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Suggested-by: Fangrui Song <maskray@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lkml.kernel.org/r/YL3q1qFO9QIRL/BA@hirez.programming.kicks-ass.net
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-25 11:26:19 +02:00
..
arch/x86 objtool/x86: Rewrite retpoline thunk calls 2022-07-25 11:26:18 +02:00
Documentation objtool: Support stack layout changes in alternatives 2022-07-25 11:26:06 +02:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
arch.h objtool: Keep track of retpoline call sites 2022-07-25 11:26:17 +02:00
Build objtool: Enable compilation of objtool for all architectures 2020-05-20 09:17:28 -05:00
builtin-check.c objtool: Move ORC logic out of check() 2020-09-01 17:19:11 -05:00
builtin-orc.c objtool: Refactor ORC section generation 2022-07-25 11:26:05 +02:00
builtin.h objtool: Implement noinstr validation 2020-04-22 10:53:50 +02:00
cfi.h objtool: Fix !CFI insn_state propagation 2020-04-22 10:53:50 +02:00
check.c objtool: Support asm jump tables 2022-07-25 11:26:18 +02:00
check.h objtool: Cache instruction relocs 2022-07-25 11:26:17 +02:00
elf.c objtool: Fix .symtab_shndx handling for elf_create_undef_symbol() 2022-07-25 11:26:19 +02:00
elf.h objtool: Add elf_create_undef_symbol() 2022-07-25 11:26:16 +02:00
Makefile objtool: Refactor ORC section generation 2022-07-25 11:26:05 +02:00
objtool.c objtool: Keep track of retpoline call sites 2022-07-25 11:26:17 +02:00
objtool.h objtool: Keep track of retpoline call sites 2022-07-25 11:26:17 +02:00
orc_dump.c objtool: Make unwind hint definitions available to other architectures 2020-09-10 10:43:13 -05:00
orc_gen.c objtool: Create reloc sections implicitly 2022-07-25 11:26:15 +02:00
special.c objtool: Skip magical retpoline .altinstr_replacement 2022-07-25 11:26:18 +02:00
special.h objtool: Refactor jump table code to support other architectures 2020-09-10 10:43:13 -05:00
sync-check.sh x86/insn: Add a __ignore_sync_check__ marker 2022-07-25 11:26:11 +02:00
warn.h objtool: Rename find_containing_func() 2020-03-25 18:28:29 +01:00
weak.c objtool: Refactor ORC section generation 2022-07-25 11:26:05 +02:00