This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR ld/18720: Properly merge non-default versioned symbol

>> 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.
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.

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, 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:

int foo() { return 0; }
asm (".symver foo,foo@VER0");

int foo() { return 1; }
asm (".symver foo,foo@VER1");

int foo() { return 2; }
asm (".symver foo,foo@VER2");

As an alternative to this (as suggested in the ld manual):

int foo_orig() { return 0; }
asm (".symver foo_orig, foo@VER0");
int foo_ver1() { return 0; }
asm (".symver foo_ver1, foo@VER1");
int foo_ver2() { return 0; }
asm (".symver foo_ver2, foo@VER2");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]