Multiple symbol versions for the same function

Florian Weimer fweimer@redhat.com
Sat Jun 23 19:48:00 GMT 2018


I have this version script:

VERSION_1 {
   global:
     func;
};
VERSION_2 {
   global:
     func;
} VERSION_1;

And this assembler file:

         .globl func
         .type func, @function
func:

         .symver func, func@VERSION_1
         .globl func_alias
         .set func_alias, func
         .symver func_alias, func@@VERSION_2

The intent is to give func both versions, with the same implementation.

But with “gcc -nostdlib -Wl,--version-script=version.script -shared”, I 
get this error:

/tmp/ccgoFKte.o:(*IND*+0x0): multiple definition of `func'
/tmp/ccgoFKte.o:(.text+0x0): first defined here

This is with binutils 2.25-5+deb8u1 on Debian mipsel.  I don't see this 
with a cross-binutils version 2.30, or native with various versions 
starting with 2.27.

Is there a way to implement what I want that works with binutils 2.25? 
I'm not sure if we want to build glibc with --allow-multiple-definition.

I'm browsing the bfd/ld commit logs, but I can't find where this was 
fixed.  Maybe we should simply require the first binutils version where 
this was fixed.

This is about __libc_start_main.  Presumably we could use 
__libc_call_main@@GLIBC_2.28 instead of __libc_start_main@@GLIBC_2.28. 
(I'm editing all the start.S files anyway for this change.)

Thanks,
Florian



More information about the Libc-alpha mailing list