Building in glibc-2.27/elf/: make[3]: Leaving directory '/root/glibc/src/glibc-2.27/elf' gcc -nostdlib -nostartfiles -shared -o /root/glibc/src/glibc-build/elf/ld.so.new \ -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs -Wl,-z,now \ /root/glibc/src/glibc-build/elf/librtld.os -Wl,--version-script=/root/glibc/src/glibc-build/ld.map \ -Wl,-soname=ld-linux.so.2 \ -Wl,-defsym=_begin=0 collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped compilation terminated. make[2]: *** [Makefile:478: /root/glibc/src/glibc-build/elf/ld.so] Error 1 Core was generated by `/usr/bin/ld -plugin /usr/lib/gcc/i686-pc-linux-gnu/8.1.0/liblto_plugin.so -plug'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0xb7e70916 in bfd_getl32 (p=0x120c8658) at /root/binutils/src/binutils-2.30/bfd/libbfd.c:561 561 return v; (gdb) bt #0 0xb7e70916 in bfd_getl32 (p=0x120c8658) at /root/binutils/src/binutils-2.30/bfd/libbfd.c:561 #1 0xb7e90ecc in bfd_elf32_swap_symbol_in (abfd=0x20c0f40, psrc=0x120c8658, pshn=0x0, dst=0xbfc60d40) at /root/binutils/src/binutils-2.30/bfd/elfcode.h:183 #2 0xb7e84383 in elf_i386_reloc_type_class (info=0x5cf0a0 <link_info>, rel_sec=0x20d4264, rela=0x218346c) at /root/binutils/src/binutils-2.30/bfd/elf32-i386.c:3965 #3 0xb7ebed3f in elf_link_sort_relocs (psec=<synthetic pointer>, info=0x5cf0a0 <link_info>, abfd=0x20c0f40) at /root/binutils/src/binutils-2.30/bfd/elflink.c:9124 #4 bfd_elf_final_link () at /root/binutils/src/binutils-2.30/bfd/elflink.c:12315 #5 0x0043a130 in ldwrite () at /root/binutils/src/binutils-2.30/ld/ldwrite.c:581 #6 0x0042013f in main (argc=<optimized out>, argv=<optimized out>) at /root/binutils/src/binutils-2.30/ld/ldmain.c:448
Please try binutils-2_30-branch
(In reply to H.J. Lu from comment #1) > Please try binutils-2_30-branch Same effect. Can I give you the value of some structures or so?
(In reply to Andreas Baumann from comment #2) > (In reply to H.J. Lu from comment #1) > > Please try binutils-2_30-branch > > Same effect. Please try https://sourceware.org/ml/binutils/2018-05/msg00182.html
(In reply to H.J. Lu from comment #3) > (In reply to Andreas Baumann from comment #2) > > (In reply to H.J. Lu from comment #1) > > > Please try binutils-2_30-branch > > > > Same effect. > > Please try > > https://sourceware.org/ml/binutils/2018-05/msg00182.html Patched the binutils-2_30-branch with the patch described. Same effect.
I can build glibc 2.27 on i686. Please provide ALL linker inputs so that I can reproduce it.
(In reply to H.J. Lu from comment #5) > I can build glibc 2.27 on i686. Please provide ALL linker inputs > so that I can reproduce it. Hope this helps: gcc -nostdlib -nostartfiles -shared -o /root/glibc/src/glibc-build/elf/ld.so.new \ -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs -Wl,-z,now \ /root/glibc/src/glibc-build/elf/librtld.os -Wl,--version-script=/root/glibc/src/glibc-build/ld.map \ -Wl,-soname=ld-linux.so.2 \ -Wl,-defsym=_begin=0 segfaults, but ommiting '-shared' works: gcc -nostdlib -nostartfiles -o /root/glibc/src/glibc-build/elf/ld.so.new \ -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs -Wl,-z,now \ /root/glibc/src/glibc-build/elf/librtld.os -Wl,--version-script=/root/glibc/src/glibc-build/ld.map \ -Wl,-soname=ld-linux.so.2 \ -Wl,-defsym=_begin=0
(In reply to Andreas Baumann from comment #6) > (In reply to H.J. Lu from comment #5) > > I can build glibc 2.27 on i686. Please provide ALL linker inputs > > so that I can reproduce it. > > Hope this helps: > > gcc -nostdlib -nostartfiles -shared -o > /root/glibc/src/glibc-build/elf/ld.so.new \ > -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs > -Wl,-z,now \ > /root/glibc/src/glibc-build/elf/librtld.os > -Wl,--version-script=/root/glibc/src/glibc-build/ld.map \ > -Wl,-soname=ld-linux.so.2 \ > -Wl,-defsym=_begin=0 > > segfaults, but ommiting '-shared' works: > > gcc -nostdlib -nostartfiles -o /root/glibc/src/glibc-build/elf/ld.so.new > \ > -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs > -Wl,-z,now \ > /root/glibc/src/glibc-build/elf/librtld.os > -Wl,--version-script=/root/glibc/src/glibc-build/ld.map \ > -Wl,-soname=ld-linux.so.2 \ > -Wl,-defsym=_begin=0 It doesn't help at all. Please add -v to gcc and show me the output of # gcc -v -nostdlib -nostartfiles -shared -o /root/glibc/src/glibc-build/elf/ld.so.new \ -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs -Wl,-z,now \ /root/glibc/src/glibc-build/elf/librtld.os -Wl,--version-script=/root/glibc/src/glibc-build/ld.map \ -Wl,-soname=ld-linux.so.2 \ -Wl,-defsym=_begin=0
(In reply to H.J. Lu from comment #7) > (In reply to Andreas Baumann from comment #6) > > (In reply to H.J. Lu from comment #5) > > > I can build glibc 2.27 on i686. Please provide ALL linker inputs > > > so that I can reproduce it. > > > > Hope this helps: > > > > gcc -nostdlib -nostartfiles -shared -o > > /root/glibc/src/glibc-build/elf/ld.so.new \ > > -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs > > -Wl,-z,now \ > > /root/glibc/src/glibc-build/elf/librtld.os > > -Wl,--version-script=/root/glibc/src/glibc-build/ld.map \ > > -Wl,-soname=ld-linux.so.2 \ > > -Wl,-defsym=_begin=0 > > > > segfaults, but ommiting '-shared' works: > > > > gcc -nostdlib -nostartfiles -o /root/glibc/src/glibc-build/elf/ld.so.new > > \ > > -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs > > -Wl,-z,now \ > > /root/glibc/src/glibc-build/elf/librtld.os > > -Wl,--version-script=/root/glibc/src/glibc-build/ld.map \ > > -Wl,-soname=ld-linux.so.2 \ > > -Wl,-defsym=_begin=0 > > It doesn't help at all. Please add -v to gcc and show me the output of > > # gcc -v -nostdlib -nostartfiles -shared -o > /root/glibc/src/glibc-build/elf/ld.so.new \ > -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs > -Wl,-z,now \ > /root/glibc/src/glibc-build/elf/librtld.os > -Wl,--version-script=/root/glibc/src/glibc-build/ld.map \ > -Wl,-soname=ld-linux.so.2 \ > -Wl,-defsym=_begin=0 Sorry about that. COMPILER_PATH=/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/:/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/:/usr/lib/gcc/i686-pc-linux-gnu/ LIBRARY_PATH=/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/:/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-nostdlib' '-nostartfiles' '-shared' '-o' '/root/glibc/src/glibc-build/elf/ld.so.new' '-mtune=generic' '-march=pentiumpro' /usr/lib/gcc/i686-pc-linux-gnu/8.1.0/collect2 -plugin /usr/lib/gcc/i686-pc-linux-gnu/8.1.0/liblto_plugin.so -plugin-opt=/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccDugu2E.res --build-id --eh-frame-hdr --hash-style=gnu -m elf_i386 -shared -o /root/glibc/src/glibc-build/elf/ld.so.new -L/usr/lib/gcc/i686-pc-linux-gnu/8.1.0 -L/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/../../.. -z combreloc -z relro --hash-style=both -z defs -z now /root/glibc/src/glibc-build/elf/librtld.os --version-script=/root/glibc/src/glibc-build/ld.map -soname=ld-linux.so.2 -defsym=_begin=0 collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped compilation terminated.
(In reply to Andreas Baumann from comment #8) > COMPILER_PATH=/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/:/usr/lib/gcc/i686-pc- > linux-gnu/8.1.0/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux- > gnu/8.1.0/:/usr/lib/gcc/i686-pc-linux-gnu/ > LIBRARY_PATH=/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/:/usr/lib/gcc/i686-pc- > linux-gnu/8.1.0/../../../:/lib/:/usr/lib/ > COLLECT_GCC_OPTIONS='-v' '-nostdlib' '-nostartfiles' '-shared' '-o' > '/root/glibc/src/glibc-build/elf/ld.so.new' '-mtune=generic' > '-march=pentiumpro' > /usr/lib/gcc/i686-pc-linux-gnu/8.1.0/collect2 -plugin > /usr/lib/gcc/i686-pc-linux-gnu/8.1.0/liblto_plugin.so > -plugin-opt=/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/lto-wrapper > -plugin-opt=-fresolution=/tmp/ccDugu2E.res --build-id --eh-frame-hdr > --hash-style=gnu -m elf_i386 -shared -o > /root/glibc/src/glibc-build/elf/ld.so.new > -L/usr/lib/gcc/i686-pc-linux-gnu/8.1.0 > -L/usr/lib/gcc/i686-pc-linux-gnu/8.1.0/../../.. -z combreloc -z relro > --hash-style=both -z defs -z now /root/glibc/src/glibc-build/elf/librtld.os > --version-script=/root/glibc/src/glibc-build/ld.map -soname=ld-linux.so.2 > -defsym=_begin=0 > collect2: fatal error: ld terminated with signal 11 [Segmentation fault], > core dumped > compilation terminated. Please send me /root/glibc/src/glibc-build/ld.map and /root/glibc/src/glibc-build/elf/librtld.os.
Created attachment 11029 [details] ld.map
Created attachment 11030 [details] librtld.os
[hjl@gnu-cfl-1 pr23194]$ cat x.c void foo (void) { } asm (".symver foo,foo@FOO"); void bar (void) { foo (); } [hjl@gnu-cfl-1 pr23194]$ cat x.map FOO { global: bar; local: *; }; [hjl@gnu-cfl-1 pr23194]$ make gcc -B./ -O2 -fno-plt -fpic -c -o x.o x.c ./ld -shared -o ld.so x.o --version-script=x.map make: *** [Makefile:34: ld.so] Segmentation fault make: *** Deleting file 'ld.so' [hjl@gnu-cfl-1 pr23194]$ The problem is bfd_find_version_for_sym doesn't match _bfd_elf_link_assign_sym_version.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=97373b2eba6077d5059370a95931b93a8b118813 commit 97373b2eba6077d5059370a95931b93a8b118813 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri May 18 14:23:41 2018 -0700 x86: Don't set eh->local_ref to 1 for versioned symbol bfd_hide_sym_by_version can't be used to check if a versioned symbol is hidden. It has to be synced with _bfd_elf_link_assign_sym_version to get the correct answer. bfd/ PR ld/23194 * elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't set eh->local_ref to 1 if a symbol is versioned and there is a version script. ld/ PR ld/23194 * testsuite/ld-i386/i386.exp: Run pr23194. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr23194.d: New file. * testsuite/ld-i386/pr23194.map: Likewise. * testsuite/ld-i386/pr23194.s: Likewise. * testsuite/ld-x86-64/pr23194.d: Likewise. * testsuite/ld-x86-64/pr23194.map: Likewise. * testsuite/ld-x86-64/pr23194.s: Likewise.
(In reply to cvs-commit@gcc.gnu.org from comment #13) > The master branch has been updated by H.J. Lu <hjl@sourceware.org>: > > https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git; > h=97373b2eba6077d5059370a95931b93a8b118813 > > commit 97373b2eba6077d5059370a95931b93a8b118813 > Author: H.J. Lu <hjl.tools@gmail.com> > Date: Fri May 18 14:23:41 2018 -0700 > > x86: Don't set eh->local_ref to 1 for versioned symbol > > bfd_hide_sym_by_version can't be used to check if a versioned symbol is > hidden. It has to be synced with _bfd_elf_link_assign_sym_version to > get the correct answer. > > bfd/ > > PR ld/23194 > * elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't > set eh->local_ref to 1 if a symbol is versioned and there is a > version script. > > ld/ > > PR ld/23194 > * testsuite/ld-i386/i386.exp: Run pr23194. > * testsuite/ld-x86-64/x86-64.exp: Likewise. > * testsuite/ld-i386/pr23194.d: New file. > * testsuite/ld-i386/pr23194.map: Likewise. > * testsuite/ld-i386/pr23194.s: Likewise. > * testsuite/ld-x86-64/pr23194.d: Likewise. > * testsuite/ld-x86-64/pr23194.map: Likewise. > * testsuite/ld-x86-64/pr23194.s: Likewise. Just patched and tested the master. Works without any problems. Thanks for the fix.
The binutils-2_30-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=88193e0fdef1646fec917bd1ebd1f1049cae660e commit 88193e0fdef1646fec917bd1ebd1f1049cae660e Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri May 18 14:23:41 2018 -0700 x86: Don't set eh->local_ref to 1 for versioned symbol bfd_hide_sym_by_version can't be used to check if a versioned symbol is hidden. It has to be synced with _bfd_elf_link_assign_sym_version to get the correct answer. bfd/ PR ld/23194 * elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't set eh->local_ref to 1 if a symbol is versioned and there is a version script. ld/ PR ld/23194 * testsuite/ld-i386/i386.exp: Run pr23194. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr23194.d: New file. * testsuite/ld-i386/pr23194.map: Likewise. * testsuite/ld-i386/pr23194.s: Likewise. * testsuite/ld-x86-64/pr23194.d: Likewise. * testsuite/ld-x86-64/pr23194.map: Likewise. * testsuite/ld-x86-64/pr23194.s: Likewise. (cherry picked from commit 97373b2eba6077d5059370a95931b93a8b118813)
Fixed for 2.31 and on 2.30 branch.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=099bb8fb97d79d03a20926d6014a5fc27a5ca75e commit 099bb8fb97d79d03a20926d6014a5fc27a5ca75e Author: H.J. Lu <hjl.tools@gmail.com> Date: Sat May 26 04:27:09 2018 -0700 ld: Add _bfd_elf_link_hide_sym_by_version bfd_hide_sym_by_version can't be used to check if a versioned symbol is hidden. This patch adds _bfd_elf_link_hide_sym_by_version to support both versioned and unversioned symbols by extracting versioned symbol check from _bfd_elf_link_assign_sym_version. bfd/ PR ld/23194 * elf-bfd.h (_bfd_elf_link_hide_sym_by_version): New. * elflink.c (_bfd_elf_link_hide_versioned_symbol): New function. Extracted from _bfd_elf_link_assign_sym_version. (_bfd_elf_link_hide_sym_by_version): New function. (_bfd_elf_link_assign_sym_version): Use _bfd_elf_link_hide_versioned_symbol. * elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Call _bfd_elf_link_hide_sym_by_version instead of bfd_hide_sym_by_version. Don't check unversioned symbol. ld/ PR ld/23194 * testsuite/ld-i386/pr23194.d: Expect only R_386_GLOB_DAT against foobar. * testsuite/ld-i386/pr23194.map: Add foobar. * testsuite/ld-x86-64/pr23194.map: Likewise. * testsuite/ld-i386/pr23194.s: Add a common foobar symbol. * testsuite/ld-x86-64/pr23194.s: Likewise. * testsuite/ld-x86-64/pr23194.d: Expect only R_X86_64_GLOB_DAT against foobar.