This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] x86-64: Resolve R_X86_64_PLT32 referencing a local symbol even if defined in another section
- From: "Fāng-ruì Sòng via binutils" <binutils at sourceware dot org>
- To: Binutils <binutils at sourceware dot org>
- Date: Wed, 12 Feb 2020 23:30:03 -0800
- Subject: Re: [PATCH] x86-64: Resolve R_X86_64_PLT32 referencing a local symbol even if defined in another section
- References: <20200213072543.blhdiffkaoxpfoqm@google.com>
- Reply-to: Fāng-ruì Sòng <maskray at google dot com>
> (begin story
>
> I taught clang to emit a call insn referencing a local symbol if the
> symbol is defined in the same translation unit. This can avoid unneeded
> PLT if the object file is linked with -shared.
>
> .globl foo
> foo:
> .Lfoo$local:
> ...
> call .Lfoo$local
> end story)
clang traditionally only supported -fno-semantic-interposition. This
local symbol optimization can avoid unneeded PLT costs in a -shared
link, in case someone argues why clang is allowed to break "ELF
semantics".
(-fPIC -fsemantic-interposition will correctly emit call foo)