linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arvind Sankar <nivedita@alum.mit.edu>
To: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Fangrui Song <maskray@google.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	jpoimboe@redhat.com, peterz@infradead.org,
	clang-built-linux@googlegroups.com,
	Nathan Chancellor <natechancellor@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] objtool: ignore .L prefixed local symbols
Date: Fri, 14 Feb 2020 19:34:01 -0500	[thread overview]
Message-ID: <20200215003400.GA3908513@rani.riverdale.lan> (raw)
In-Reply-To: <20200215000556.GA3876732@rani.riverdale.lan>

On Fri, Feb 14, 2020 at 07:05:57PM -0500, Arvind Sankar wrote:
> On Fri, Feb 14, 2020 at 02:20:46PM -0800, Fangrui Song wrote:
> > On 2020-02-14, Arvind Sankar wrote:
> > >
> > >I was testing with hidden/protected visibility, I see you want this for
> > >the no-semantic-interposition case. Actually a bit more testing shows
> > >some peculiarities even with hidden visibility. With the below, the call
> > >and lea create relocations in the object file, but the jmp doesn't. ld
> > >does avoid creating a plt for this though.
> > >
> > >	.text
> > >	.globl foo, bar
> > >	.hidden foo
> > >	bar:
> > >		call	foo
> > >		leaq	foo(%rip), %rax
> > >		jmp	foo
> > >
> > >	foo:	ret
> > 
> > Yes, GNU as is inconsistent here.  While fixing
> > https://sourceware.org/ml/binutils/2020-02/msg00243.html , I noticed
> > that the rule is quite complex. There are definitely lots of places to
> > improve.  clang 10 emits relocations consistently.
> > 
> >    call	foo              # R_X86_64_PLT32
> >    leaq	foo(%rip), %rax  # R_X86_64_PC32
> >    jmp	foo              # R_X86_64_PLT32
> > 
> 
> I guess the reason why is that jmp instructions can be optimized to use
> 8-bit signed offset if the destination is close enough, so the assembler
> wants to go through them anyway to check, while such optimization is not
> possible for the call and lea.
> 
> clang 9 emits no relocations for me, unless @PLT/@GOTPCREL is explicitly
> used. Has that changed? (Just using clang -o test.o test.s on that
> assembler, not too familiar with invokation syntax)

Actually, wait, it does that even with default visibility. The only way
to make it allow for symbol interposition is to explicitly use @PLT etc.
Is the only reason you're adding these local symbols then is to work
around GNU as adding PLT relocations automatically for call foo?

  reply	other threads:[~2020-02-15  0:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13 18:47 [PATCH] objtool: ignore .L prefixed local symbols Nick Desaulniers
2020-02-13 19:20 ` Fangrui Song
2020-02-14  6:16   ` Arvind Sankar
2020-02-14 18:05     ` Fangrui Song
2020-02-14 20:42       ` Arvind Sankar
2020-02-14 22:20         ` Fangrui Song
2020-02-15  0:05           ` Arvind Sankar
2020-02-15  0:34             ` Arvind Sankar [this message]
2020-02-13 22:17 ` Josh Poimboeuf
2020-02-13 22:37   ` Fangrui Song
2020-02-13 23:16     ` Josh Poimboeuf
2020-02-13 22:55   ` Nick Desaulniers

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=20200215003400.GA3908513@rani.riverdale.lan \
    --to=nivedita@alum.mit.edu \
    --cc=clang-built-linux@googlegroups.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maskray@google.com \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    /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).