[PATCH] PR ld/18720: Properly merge non-default versioned symbol
H.J. Lu
hjl.tools@gmail.com
Mon Jul 27 17:35:00 GMT 2015
On Mon, Jul 27, 2015 at 10:15 AM, Cary Coutant <ccoutant@gmail.com> wrote:
>>> But it's not -- only foo@FOO is defined in main. If you think it's
>>> right that main should also have an unversioned definition, then why
>>> should the call from bar() to foo() bind to the one in the DSO? And
>>> which foo() are you expecting the indirect reference to bind to?
>>
>> Here is our disagreement on this code:
>>
>> +#include <stdio.h>
>> +
>> +void
>> +foo (void)
>> +{
>> + printf ("MAIN\n");
>> +}
>> +
>> +asm (".symver foo,foo@FOO");
>>
>> To me, this defines foo and foo@FOO. Both points to the same
>> address. This is how gas and ld work on symbol versioning for
>> a long time. I don't think we should change it just because gold
>> behaves differently.
>
> OK, if you think that's correct behavior, you didn't answer why you
> still expect the call from bar() to bind to the foo() in the DSO.
It is because foo@FOO in main is hidden from DSO. It
will only be used by ld.so to resolve references to foo@FOO,
not the naked "foo".
> Without the .symver, both linkers bind to the foo() in MAIN.
>
> I don't think we should change it *just because gold behaves
> differently* -- I'm working on a fix now, but it's a bit messy. It's
> just that I *don't* think it should define both foo and foo@FOO.
>
> In the gas documentation, it's clear that .symver should be used with
> different names. It always uses "name" and "name2":
>
> .symver name, name2@nodename
>
> There's nothing explaining what should happen when "name" and "name2"
> are the same.
>
> The ld documentation also never shows any examples where the two are
> not different symbols.
Improvements to ld and gas manuals are more than welcome.
> Only in the testsuites can you find examples where they are the same
> symbol, but I don't think the testsuites should be the authority when
> it comes to undefined behavior.
To me, the GNU ld testsuite is the authority of GNU linker behavior.
The undefined behaviors are those not covered by the GNU ld testsuite.
> To me, if you're going to allow the two names to be the same, it
> should define only one symbol. That would allow a library developer to
> maintain multiple versions of a function in separate source files,
> like this:
>
The current gas/linker provide flexibility to support both ways.
Here is the updated patch to check the address of foo in
main.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Properly-merge-non-default-versioned-symbol.patch
Type: text/x-patch
Size: 14083 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20150727/54567090/attachment.bin>
More information about the Binutils
mailing list