https://sourceware.org/bugzilla/show_bug.cgi?id=33665

            Bug ID: 33665
           Summary: multiple definition of `foo' when using multiple
                    symver
           Product: binutils
           Version: 2.45
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: dante at cadence dot com
  Target Milestone: ---

This is the same strategy used Fedora to patch OpenSSL
(0116-version-aliasing.patch)

$ cat foo.c
__attribute__ ((symver ("foo@@FOO_3.1.0"), symver ("foo@FOO_3.2.0")))
void foo(void) {}

$ cat foo.ld
FOO_3.1.0 {
    global:
        foo;
};

FOO_3.2.0 {
    global:
        foo;
} FOO_3.1.0;

$ gcc -c foo.c -o foo.o

$ gcc -shared foo.o -o foo.so -Wl,--version-script=foo.ld
ld: foo.o:(*IND*+0x0): multiple definition of `foo'; foo.o:foo.c:(.text+0x0):
first defined here
collect2: error: ld returned 1 exit status


This works:

$ cat foo.ld
FOO_3.1.0 {
    global:
        foo*;
};

FOO_3.2.0 {
    global:
        foo*;
} FOO_3.1.0;



$ gcc --version
gcc (Cadence) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ld -V
GNU ld (GNU Binutils) 2.45
  Supported emulations:
   elf_x86_64
   elf32_x86_64
   elf_i386
   elf_iamcu

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to