[v3] symbol versioning fixups

Jakub Jelinek jakub@redhat.com
Thu Jun 16 10:16:00 GMT 2005


On Thu, Jun 16, 2005 at 12:02:20PM +0200, Paolo Carlini wrote:
> Ok, sorry, disregard this: I got sidetracked by the word
> "compatibility", which is actually about 3.4.0 vs 3.4.5, not about 3.4.x
> vs 4.0.0.
> 
> Actually, now I see more clearly that this whole issue is about the
> above delicate point, as explained by Benjamin in the second paragraph,
> not about forward compatibility per se between 3.4 and 4.0, which is OK
> anyway.
> 
> To summarize, the only minor thing which is still not clear to me is
> char_traits::eq...

WIth GNU symbol versioning, when you want to export some symbol in several
symbol versions (say foo@GLIBCXX_3.4 and foo@@GLIBCXX_3.4.5), the usual way
to do that is:
int __old_foo () { return 0; }
int __new_foo () { return 1; }
asm (".symver __old_foo, foo@GLIBCXX_3.4");
asm (".symver __new_foo, foo@@GLIBCXX_3.4.5");
plus version script mentioning the foo twice, once in GLIBCXX_3.4 and once
in GLIBCXX_3.4.5 version's global symbols.

If you want to export the same function at 2 versions, you can do:
int __real_foo () { return 0; }
extern int __old_foo () __attribute__((alias ("__real_foo")));
asm (".symver __old_foo, foo@GLIBCXX_3.4");
asm (".symver __real_foo, foo@@GLIBCXX_3.4.5");

Now, without asm renames for eq, you end up basically with:
int foo () { return 0; }
extern int __old_foo () __attribute__((alias ("foo")));
extern int __new_foo () __attribute__((alias ("foo")));
asm (".symver __old_foo, foo@GLIBCXX_3.4");
asm (".symver __new_foo, foo@@GLIBCXX_3.4.5");

but this is something most GNU linkers either crash on, or do
weird unexpected things, because the foo symbol is present
both as versioned (with 2 versions) and unversioned in the
same object.

	Jakub



More information about the Gcc-patches mailing list