V2 [PATCH] gas: Extend .symver directive

Fangrui Song i@maskray.me
Tue Apr 7 23:58:42 GMT 2020


On 2020-04-07, H.J. Lu wrote:
>On Tue, Apr 7, 2020 at 2:23 PM Fangrui Song <i@maskray.me> wrote:
>>
>> On 2020-04-07, H.J. Lu via Binutils wrote:
>> >On Tue, Apr 7, 2020 at 5:55 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>> >>
>> >> On Apr 07 2020, H.J. Lu wrote:
>> >>
>> >> > The optional argument VISIBILITY updates the visibility of
>> >> > the original symbol.  The valid visibilities are 'local', 'hidden', and
>> >> > 'remove'.  The 'local' visibility makes the original symbol a local
>> >> > symbol (*note Local::).  The 'hidden' visibility sets the visibility of
>> >> > the original symbol to 'hidden' (*note Hidden::).  The 'remove'
>> >> > visibility removes the original symbol from the symbol table.  If
>> >> > visibility isn't specified, the original symbol is unchanged.
>> >>
>> >> Looks good.
>> >
>> >Here is the updated patch.
>> >
>> >--
>> >H.J.
>>
>> Let me summarize the current status:
>>
>> @@@ has the renaming semantics. (invented in 2000)
>> @ and @@ has the copying semantics. The original symbol remains which is usually cumbersome.
>>
>> We have received some requests:
>>
>> * Have a way to not retain the original symbol
>> * Have a way to define multiple versions `.symver something,foo@v1; .symver something,foo@v2. symver something,foo@@v3`
>>
>>
>> We have many choices.
>>
>> A. make @ @@ similar to @@@
>>    For @@, because of the linking rule (a @@ definition can satisfy a
>>    referenced without a version), there should be no difference.
>>
>>    For @, this will be a semantic break. Personally I don't think this
>>    matters. I believe 99% projects don't need the original symbol and
>>    will not notice anything. I also checked with FreeBSD developers.
>
>The original symbol name is used in glibc to bypass PLT within
>libc.so.

This does not seem correct. By convention, the hidden aliases are those prefixed with __
They are called to bypass PLT (STV_HIDDEN implies the non-preemptible property).
The original symbol does not have the prefix.

When a linker sees memcpy@@GLIBC_2.14 , basically it inserts both "memcpy" and
"memcpy@GLIBC_2.14" into the symbol table.  Both a reference without a version
"memcpy" and a reference with a version "memcpy@GLIBC_2.14" can be satisfied.

If the definition of "memcpy" also exists, I think it is somewhat special cased
in GNU ld and/or gold. In GNU ld, the actual implementation may be more complex
with indirect symbol involved. I believe the whole thing can be simplified a
lot by using renaming semantic. I debugged this area last year and may
misremember something.


More information about the Binutils mailing list