After switching to binutils 2.38 openjdk13 build failed on i686 with error: /usr/bin/ld: /tmp/B.zx6ygnoi/BUILD/jdk13u-jdk-13.0.10-ga/build/linux-x86-server-release/hotspot/variant-server/libjvm/objs/acce ss.o: warning: relocation in read-only section `.text._ZN14AccessInternal15RuntimeDispatchILy16464EP7oopDescLNS_11BarrierTypeE1 1EE11equals_initES2_S2_[_ZN14AccessInternal15RuntimeDispatchILy16464EP7oopDescLNS_11BarrierTypeE11EE11equals_initES2_S2_]' /usr/bin/ld: BFD (GNU Binutils) 2.38 assertion fail elfxx-x86.c:529 collect2: fatal error: ld terminated with signal 11 [Segmentation fault] compilation terminated. Just before upgrading binutils another build was successful with binutils 2.37. Note that x86_64 build succeeded with binutils 2.38. gcc 11.2.0 (with most of patches from gcc-11 patch) glibc 2.35
Please provide ALL linker inputs so that I can reproduce it on totally different machines.
Created attachment 13980 [details] the version script
I have a similar issue with openjdk-17.0.2 (in a 32 bit VM): /usr/bin/ld: /sources/openjdk/jdk17u-jdk-17.0.2-ga/build/linux-x86-server-release/hotspot/variant-server/libjvm/objs/adaptiveSizePolicy.o: warning: relocation in read-only section `.text' /usr/bin/ld: BFD (GNU Binutils) 2.38 assertion fail ../../bfd/elfxx-x86.c:529 collect2: fatal error: ld terminated with signal 11 [Segmentation fault] compilation terminated. The command line leading to that is: /usr/bin/g++ -Wl,-z,defs -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-O1 -Wl,--hash-style=gnu -march=i586 -m32 -shared -m32 -Wl,-version-script=/sources/openjdk/jdk17u-jdk-17.0.2-ga/build/linux-x86-server-release/hotspot/variant-server/libjvm/mapfile -Wl,-soname=libjvm.so -o /sources/openjdk/jdk17u-jdk-17.0.2-ga/build/linux-x86-server-release/support/modules_libs/java.base/server/libjvm.so @/sources/openjdk/jdk17u-jdk-17.0.2-ga/build/linux-x86-server-release/hotspot/variant-server/libjvm/objs/_BUILD_LIBJVM_objectfilenames.txt -lm -ldl -lpthread -lrt I have attached the "version-script". The compressed directory objs (that contains all the object files unless I've missed something) will be attached next
Problem is the compressed objs directory is ~240MB I cannot attach it. Don't know I can reduce it, sorry.
Created attachment 13983 [details] the object file where the failure occurs
Confirmed that issue also occurs on glibc 2.34. In my case command line is: /usr/bin/i686-pld-linux-g++ -Wl,--hash-style=both -Wl,-z,defs -Wl,-z,relro -Wl,-z,noexecstack -Wl,-O1 -march=i586 -m32 -Wl,--as-needed -Wl,--no-copy-dt-needed-entries -Wl,-z,relro -Wl,-z,combreloc -static-libstdc++ -static-libgcc -shared -m32 -Wl,--as-needed -Wl,--no-copy-dt-needed-entries -Wl,-z,relro -Wl,-z,combreloc -Wl,-version-script=/home/users/atler/rpm/packages/BUILD.i686-linux/jdk13u-jdk-13.0.10-ga/build/linux-x86-server-release/hotspot/variant-server/libjvm/mapfile -Wl,-soname=libjvm.so -o /home/users/atler/rpm/packages/BUILD.i686-linux/jdk13u-jdk-13.0.10-ga/build/linux-x86-server-release/support/modules_libs/java.base/server/libjvm.so @/home/users/atler/rpm/packages/BUILD.i686-linux/jdk13u-jdk-13.0.10-ga/build/linux-x86-server-release/hotspot/variant-server/libjvm/objs/_BUILD_LIBJVM_objectfilenames.txt -lm -ldl -lpthread version script: http://jpalus.fastmail.com/version-script all object files: http://jpalus.fastmail.com/objs.tar.xz
(In reply to Jan Palus from comment #6) > Confirmed that issue also occurs on glibc 2.34. > > In my case command line is: > > /usr/bin/i686-pld-linux-g++ -Wl,--hash-style=both -Wl,-z,defs -Wl,-z,relro > -Wl,-z,noexecstack -Wl,-O1 -march=i586 -m32 -Wl,--as-needed > -Wl,--no-copy-dt-needed-entries -Wl,-z,relro -Wl,-z,combreloc > -static-libstdc++ -static-libgcc -shared -m32 -Wl,--as-needed > -Wl,--no-copy-dt-needed-entries -Wl,-z,relro -Wl,-z,combreloc > -Wl,-version-script=/home/users/atler/rpm/packages/BUILD.i686-linux/jdk13u- > jdk-13.0.10-ga/build/linux-x86-server-release/hotspot/variant-server/libjvm/ > mapfile -Wl,-soname=libjvm.so -o > /home/users/atler/rpm/packages/BUILD.i686-linux/jdk13u-jdk-13.0.10-ga/build/ > linux-x86-server-release/support/modules_libs/java.base/server/libjvm.so > @/home/users/atler/rpm/packages/BUILD.i686-linux/jdk13u-jdk-13.0.10-ga/build/ > linux-x86-server-release/hotspot/variant-server/libjvm/objs/ > _BUILD_LIBJVM_objectfilenames.txt -lm -ldl -lpthread > > version script: http://jpalus.fastmail.com/version-script > all object files: http://jpalus.fastmail.com/objs.tar.xz Please provide @/home/users/atler/rpm/packages/BUILD.i686-linux/jdk13u-jdk-13.0.10-ga/build/linux-x86-server-release/hotspot/variant-server/libjvm/objs/_BUILD_LIBJVM_objectfilenames.txt
(In reply to H.J. Lu from comment #7) > > Please provide > @/home/users/atler/rpm/packages/BUILD.i686-linux/jdk13u-jdk-13.0.10-ga/build/ > linux-x86-server-release/hotspot/variant-server/libjvm/objs/ > _BUILD_LIBJVM_objectfilenames.txt No need for it.
To be complete, my toolchain is: gcc-11.2.0, glibc-2.35, bintuils-2.38 I've installed binutils-2.37 and run the exact same command (that is, not recompiling the object files). Still, I see the warning: /usr/bin/ld: /sources/openjdk/jdk17u-jdk-17.0.2-ga/build/linux-x86-server-release/hotspot/variant-server/libjvm/objs/adaptiveSizePolicy.o: warning: relocation in read-only section `.text' But then I see: /usr/bin/ld: warning: creating DT_TEXTREL in a shared object and the link succeeds. Trying to bisect from 2.37 to 2.38
It is caused by 3747999c6bd40a7ac905ef306a82214b336067b6 is the first bad commit commit 3747999c6bd40a7ac905ef306a82214b336067b6 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Dec 27 10:13:06 2021 -0800 ld: Extract _bfd_elf_link_iterate_on_relocs
[hjl@gnu-tgl-3 pr28894]$ cat x.s .text addl foo@INDNTPOFF, %eax .section .tbss,"awT",@nobits .globl foo .hidden foo foo: .byte 0 [hjl@gnu-tgl-3 pr28894]$ gcc -c -m32 x.s [hjl@gnu-tgl-3 pr28894]$ ld -shared -m elf_i386 x.o ld: BFD (Linux/GNU Binutils) 2.38.50.0.1.20220212 assertion fail /export/linux/src/binutils/binutils/bfd/elfxx-x86.c:547 Segmentation fault (core dumped) [hjl@gnu-tgl-3 pr28894]$
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3319ba7a8d6a42ba071d691789bc184632399331 commit 3319ba7a8d6a42ba071d691789bc184632399331 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Feb 15 15:03:02 2022 -0800 i386: Update I386_NEED_DYNAMIC_RELOC_TYPE_P for DT_TEXTREL Update I386_NEED_DYNAMIC_RELOC_TYPE_P to allow R_386_TLS_IE for relocation in read-only section. bfd/ PR ld/28894 * elfxx-x86.h (I386_NEED_DYNAMIC_RELOC_TYPE_P): Allow R_386_TLS_IE. ld/ PR ld/28894 * testsuite/ld-i386/i386.exp: Run pr28894. * testsuite/ld-i386/pr28894.d: New file. * testsuite/ld-i386/pr28894.s: Likewise.
The binutils-2_38-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ae1cab7d3f39686d9c7ddadbac297e9ae76ffccf commit ae1cab7d3f39686d9c7ddadbac297e9ae76ffccf Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Feb 15 15:03:02 2022 -0800 i386: Update I386_NEED_DYNAMIC_RELOC_TYPE_P for DT_TEXTREL Update I386_NEED_DYNAMIC_RELOC_TYPE_P to allow R_386_TLS_IE for relocation in read-only section. bfd/ PR ld/28894 * elfxx-x86.h (I386_NEED_DYNAMIC_RELOC_TYPE_P): Allow R_386_TLS_IE. ld/ PR ld/28894 * testsuite/ld-i386/i386.exp: Run pr28894. * testsuite/ld-i386/pr28894.d: New file. * testsuite/ld-i386/pr28894.s: Likewise. (cherry picked from commit 3319ba7a8d6a42ba071d691789bc184632399331)
Fixed for 2.39 and on 2.38 branch.
Confirmed openjdk builds fine with above fix. Thanks!
A little late to the party, openjdk-17 builds again too. Thanks for the quick fix.