Re: [PATCH] objtool: support symtab_shndx during dump

From: Josh Poimboeuf
Date: Thu Sep 03 2020 - 11:36:09 EST


On Wed, Aug 12, 2020 at 10:57:11AM -0700, Kristen Carlson Accardi wrote:
> When getting the symbol index number, make sure to use the
> extended symbol table information in order to support symbol
> index's greater than 64K.

"indexes"

> if (GELF_ST_TYPE(sym.st_info) == STT_SECTION) {
> - scn = elf_getscn(elf, sym.st_shndx);
> + if ((sym.st_shndx > SHN_UNDEF &&
> + sym.st_shndx < SHN_LORESERVE) ||
> + (xsymtab && sym.st_shndx == SHN_XINDEX)) {
> + if (sym.st_shndx != SHN_XINDEX)
> + shndx = sym.st_shndx;

The sym.st_shndx checks are redundant, if 'sym.st_shndx == SHN_XINDEX'
then 'sym.st_shndx != SHN_XINDEX' can't be true.

Actually I think this can be even further simplified to something like

if (!shndx)
shndx = sym.st_shndx;

--
Josh