linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
To: <rostedt@goodmis.org>
Cc: <ardb@kernel.org>, <linux-arm-kernel@lists.infradead.org>,
	<linux-kbuild@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>,
	<linux-toolchains@vger.kernel.org>, <mark-pk.tsai@mediatek.com>,
	<matthias.bgg@gmail.com>, <mhelsley@vmware.com>,
	<peterz@infradead.org>, <samitolvanen@google.com>,
	<yj.chiang@mediatek.com>
Subject: Re: [PATCH] recordmcount: avoid using ABS symbol as reference
Date: Tue, 8 Jun 2021 01:31:38 +0800	[thread overview]
Message-ID: <20210607173138.3882-1-mark-pk.tsai@mediatek.com> (raw)
In-Reply-To: <20210607094433.473100d9@oasis.local.home>

> On Mon, 7 Jun 2021 13:44:21 +0200
> Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > There's an extended section header index section for just that. And
> > recordmcount actually seems to use that as well.
> > 
> > I can't seem to find enough of the thread to figure out what the actual
> > problem is though. The lore archive doesn't have anything prior to this
> > message.
> > 
> > One should only use st_shndx when >SHN_UDEF and <SHN_LORESERVE. When
> > SHN_XINDEX, then use .symtab_shndx.
> > 
> > Apparently you've found a case where neither is true? In that case
> > objtool seems to use shndx 0. A matching recordmcount patch would be
> > something like this.

Hi Peter,

Should I resend the below patch as v2?

> 
> Mark-PK,
> 
> Does the below patch fix it for you too (if you backport it to your
> kernel). I much rather have recordmcount match objtool, as one day the
> two will hopefully merge to one executable.
> 
> -- Steve
> 

Yes, this patch fix it.

> 
> > 
> > 
> > diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
> > index f9b19524da11..d99cc0aed6fe 100644
> > --- a/scripts/recordmcount.h
> > +++ b/scripts/recordmcount.h
> > @@ -194,13 +194,18 @@ static unsigned int get_symindex(Elf_Sym const *sym, Elf32_Word const *symtab,
> >  	unsigned long offset;
> >  	int index;
> >  
> > -	if (sym->st_shndx != SHN_XINDEX)
> > +	if (sym->st_shndx > SHN_UDEF &&
> > +	    sym->st_shndx < SHN_LORESERVE)
> >  		return w2(sym->st_shndx);
> >  
> > -	offset = (unsigned long)sym - (unsigned long)symtab;
> > -	index = offset / sizeof(*sym);
> > +	if (sym->st_shndx == SHN_XINDEX) {
> > +		offset = (unsigned long)sym - (unsigned long)symtab;
> > +		index = offset / sizeof(*sym);
> >  
> > -	return w(symtab_shndx[index]);
> > +		return w(symtab_shndx[index]);
> > +	}
> > +
> > +	return 0;
> >  }
> >  
> >  static unsigned int get_shnum(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0)

  reply	other threads:[~2021-06-07 17:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210607074258.32322-1-mark-pk.tsai@mediatek.com>
     [not found] ` <20210607080626.32612-1-mark-pk.tsai@mediatek.com>
2021-06-07  9:50   ` [PATCH] recordmcount: avoid using ABS symbol as reference Ard Biesheuvel
2021-06-07 10:32     ` Mark-PK Tsai
2021-06-07 11:44     ` Peter Zijlstra
2021-06-07 13:18       ` Mark-PK Tsai
2021-06-07 13:44       ` Steven Rostedt
2021-06-07 17:31         ` Mark-PK Tsai [this message]
2021-06-07 15:40       ` Peter Zijlstra
2021-06-08  1:15         ` Mark-PK Tsai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210607173138.3882-1-mark-pk.tsai@mediatek.com \
    --to=mark-pk.tsai@mediatek.com \
    --cc=ardb@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mhelsley@vmware.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=samitolvanen@google.com \
    --cc=yj.chiang@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).