Messages in this thread | | | Date | Fri, 4 Sep 2020 09:17:20 -0500 | From | Josh Poimboeuf <> | Subject | Re: [PATCH] objtool: support symtab_shndx during dump |
| |
On Fri, Sep 04, 2020 at 09:54:29AM +0200, Miroslav Benes wrote: > On Thu, 3 Sep 2020, Josh Poimboeuf wrote: > > > On Wed, Aug 12, 2020 at 10:57:11AM -0700, Kristen Carlson Accardi wrote: > > > > > 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. > > It is probably a copy-paste from read_symbols() in elf.c, where the logic > is different.
Yeah.
> > Actually I think this can be even further simplified to something like > > > > if (!shndx) > > shndx = sym.st_shndx; > > This relies on the fact that gelf_getsymshndx() always initializes shndx, > no? I think it would be better to initialize it in orc_dump() too. Safer > and easier to read. It applies to Kristen's patch as well. I missed that.
Agreed.
-- Josh
| |