lkml.org 
[lkml]   [2020]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2020-09-04 16:19    [W:0.056 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site