]> git.baikalelectronics.ru Git - kernel.git/commit
objtool: Fix .symtab_shndx handling for elf_create_undef_symbol()
authorPeter Zijlstra <peterz@infradead.org>
Mon, 7 Jun 2021 09:45:58 +0000 (11:45 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 10 Jun 2021 08:08:24 +0000 (10:08 +0200)
commit1205cbf5e3d80b45320183f5d049680a66fad569
tree6343458bd05d3a2021ca0cdb3f62a13650dc01b2
parent7f6864a054c90434e53660b2e80755898468c094
objtool: Fix .symtab_shndx handling for elf_create_undef_symbol()

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: 34ce688a39e9 ("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
tools/objtool/elf.c