[hjl@gnu-efi-2 pr87698]$ cat test.c void foo () { } [hjl@gnu-efi-2 pr87698]$ cat test2.c void foo (void); void bar (void) { foo (); } [hjl@gnu-efi-2 pr87698]$ cat x.t { local: *; }; [hjl@gnu-efi-2 pr87698]$ make gcc -flto -ffat-lto-objects -fPIC -O2 -g -c -o test.o test.c gcc -flto -ffat-lto-objects -fPIC -O2 -g -c -o test2.o test2.c gcc -shared -o x.so test.o test2.o -Wl,--version-script,x.t readelf -sW x.so | grep foo 5: 0000000000000000 0 NOTYPE GLOBAL DEFAULT ABS foo [hjl@gnu-efi-2 pr87698]$
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0a640d719684f25bdb88ae60148c6978e6131701 commit 0a640d719684f25bdb88ae60148c6978e6131701 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Oct 24 18:08:13 2018 -0700 ELF: Hide symbols defined in discarded input sections When assigning symbol version, we should hide debug symbols defined in discarded sections from IR objects so that they can be removed later. bfd/ PR ld/23818 * elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols defined in discarded input sections. ld/ PR ld/23818 * testsuite/ld-plugin/lto.exp: Run PR ld/23818 test. * testsuite/ld-plugin/pr23818.d: New file. * testsuite/ld-plugin/pr23818.t: Likewise. * testsuite/ld-plugin/pr23818a.c: Likewise. * testsuite/ld-plugin/pr23818b.c: Likewise.
Fixed for 2.32.
Thanks, I will check that this indeed fixes my case with libssh2. I understand this problem is not really wide and might actually affect just me since I don't expect that using -ffat-lto-objects is very common, but do you think this commit deserves to be backported on branch 2.31, or do you prefer I patch it manually on my side until 2.32 is out ? Cheers, Romain
(In reply to Romain Geissler from comment #3) > Thanks, I will check that this indeed fixes my case with libssh2. > > I understand this problem is not really wide and might actually affect just > me since I don't expect that using -ffat-lto-objects is very common, but do > you think this commit deserves to be backported on branch 2.31, or do you > prefer I patch it manually on my side until 2.32 is out ? Please verify that it does fix your problem first.
After rebuilding libssh2 and a few other open source libraries, now indeed I don't see any more these odd absolute relocations, and now ld.lld happily accepts them as valid input .so files. So it looks like you fixed it ;) Is it ok to backport in release branch 2.31 ? Cheers, Romain
(In reply to Romain Geissler from comment #5) > Is it ok to backport in release branch 2.31 ? Please request backport on the binutils mailing list.
The binutils-2_31-branch branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=84fdbf1a2c901965414eafc96e3bd15fc72ac123 commit 84fdbf1a2c901965414eafc96e3bd15fc72ac123 Author: Nick Clifton <nickc@redhat.com> Date: Tue Nov 6 16:06:52 2018 +0000 When assigning symbol version, we should hide debug symbols defined in discarded sections from IR objects so that they can be removed later. bfd PR ld/23818 * elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols defined in discarded input sections. ld * testsuite/ld-plugin/lto.exp: Run PR ld/23818 test. * testsuite/ld-plugin/pr23818.d: New file. * testsuite/ld-plugin/pr23818.t: Likewise. * testsuite/ld-plugin/pr23818a.c: Likewise. * testsuite/ld-plugin/pr23818b.c: Likewise.