Package versions: binutils-2.35.2-24.el9.x86_64 gcc-11.3.1-2.1.el9.x86_64 This script produces a shared object with the expected alias: cat > t.c <<EOF int __attribute__ ((symver ("OPENSSL_strcasecmp.1"), symver ("OPENSSL_strcasecmp@@OPENSSL_3.0.3"))) OPENSSL_strcasecmp (const char *a, const char *b) { return 0; } EOF cat > t.lds <<EOF OPENSSL_3.0.1 { global: OPENSSL_strcasecmp; local: *; }; OPENSSL_3.0.3 { global: OPENSSL_strcasecmp; local: *; } OPENSSL_3.0.1; EOF gcc -Wall -O2 -shared -fpic t.c -Wl,--version-script t.lds But replacing the final command does not: gcc -flto -Wall -O2 -shared -fpic t.c -Wl,--version-script t.lds /usr/bin/ld: /tmp/ccDIqhWD.ltrans0.ltrans.o: in function `OPENSSL_strcasecmp': <artificial>:(.text+0x0): multiple definition of `OPENSSL_strcasecmp' /usr/bin/ld: /tmp/ccDIqhWD.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `OPENSSL_strcasecmp' collect2: error: ld returned 1 exit status The assembler difference from LTO non-LTO mode appears to be: .LFE0: .size OPENSSL_strcasecmp, .-OPENSSL_strcasecmp - .symver OPENSSL_strcasecmp, OPENSSL_strcasecmp.1 .symver OPENSSL_strcasecmp, OPENSSL_strcasecmp@@OPENSSL_3.0.3 + .symver OPENSSL_strcasecmp, OPENSSL_strcasecmp.1 .ident "GCC: (GNU) 11.3.1 20220421 (Red Hat 11.3.1-2)" .section .note.GNU-stack,"",@progbits And the symbol table order is similarly transposed: 7: 0000000000000000 0 SECTION LOCAL DEFAULT 4 8: 0000000000000000 3 FUNC GLOBAL DEFAULT 1 OPENSSL_strcasecmp - 9: 0000000000000000 3 FUNC GLOBAL DEFAULT 1 OPENSSL_strcasecmp@@OPENSSL_3.0.3 - 10: 0000000000000000 3 FUNC GLOBAL DEFAULT 1 OPENSSL_strcasecmp.1 + 9: 0000000000000000 3 FUNC GLOBAL DEFAULT 1 OPENSSL_strcasecmp.1 + 10: 0000000000000000 3 FUNC GLOBAL DEFAULT 1 OPENSSL_strcasecmp@@OPENSSL_3.0.3 I'm not sure if these are the differences that trigger the linker failure. Nick, does this look like a binutils issue to you?
(In reply to Florian Weimer from comment #0) Hi Florian, > gcc -Wall -O2 -shared -fpic t.c -Wl,--version-script t.lds > gcc -flto -Wall -O2 -shared -fpic t.c -Wl,--version-script t.lds > /usr/bin/ld: /tmp/ccDIqhWD.ltrans0.ltrans.o: in function > `OPENSSL_strcasecmp': > <artificial>:(.text+0x0): multiple definition of `OPENSSL_strcasecmp' > Nick, does this look like a binutils issue to you? Definitely. Well 90%. I suppose that there is a possibility that this will turn out to be a bug in the lto plugin, rather than the linker itself. Would you mind filing this upstream ? Cheers Nick
Never mind. I have found that the bug was fixed upstream some time between 2.37 and 2.38. Reassigning to me...
Found it: https://sourceware.org/bugzilla/show_bug.cgi?id=28264 Working on a patch...
Fixed in binutils-2.35.2-26.el9
Verified with binutils-2.35.2-33.el9.
Right - should be fixed in binutils-2.35.2-35.el9
Verified with binutils-2.35.2-35.el9.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (binutils bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2023:2548