Created attachment 9072 [details] Files used by ld When compiling glibc with linker flag Bsymbolic-functions, I got: ld: BFD (GNU Binutils) 2.26.51.20160307 internal error, aborting at elf64-x86-64.c:4247 in elf_x86_64_relocate_section No assert if Bsymbolic-functions is removed. binutils 2.26 shows same issue. The linker command line was: ld -plugin ./liblto_plugin.so -plugin-opt=lto-wrapper -plugin-opt=-fresolution=/tmp/ccQP0SYe.res --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -O1 -Bsymbolic-functions -shared -o libc.so -e __libc_main -L. -O1 -z defs -dynamic-linker=/lib/ld-linux-x86-64.so.2 --version-script=libc.map -soname=libc.so.6 -z combreloc -z relro --hash-style=both abi-note.o soinit.os libc_pic.os sofini.os interp.os ld.so -lgcc -T shlib.lds
Is this a regression?
[hjl@gnu-6 pr19784]$ cat foo.c static int zero (int x) { return 0; } void * foo_ifunc (void) __asm__ ("foo"); void * foo_ifunc (void) { return zero ; } __asm__(".type foo, %gnu_indirect_function"); __asm__(".hidden foo"); [hjl@gnu-6 pr19784]$ cat bar.c extern int foo (void) __attribute__ ((visibility("hidden"))); int bar () { return foo (); } [hjl@gnu-6 pr19784]$ make LD=ld gcc -pie -B./ -fPIC -O -c -o foo.o foo.c ld -Bsymbolic-functions -shared -o libfoo.so foo.o bar.o ld: BFD (Linux/GNU Binutils) 2.26.51.0.2.20160302 internal error, aborting at /net/gnu-6/export/linux/src/binutils/binutils/bfd/elf64-x86-64.c:4283 in elf_x86_64_relocate_section ld: Please report this bug. Makefile:11: recipe for target 'libfoo.so' failed make: *** [libfoo.so] Error 1 [hjl@gnu-6 pr19784]$
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d1ed1c7d69e6656de213b12594e702afec31a66d commit d1ed1c7d69e6656de213b12594e702afec31a66d Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Mar 8 09:42:01 2016 -0800 Handle local IFUNC symbols in shared object Increment PLT reference count for locally defined local IFUNC symbols in shared object since STT_GNU_IFUNC symbol must go through PLT even if it is locally defined and undefined symbol may turn out to be a STT_GNU_IFUNC symbol later. bfd/ PR ld/19784 * elf32-i386.c (elf_i386_check_relocs): Increment PLT reference count for locally defined local IFUNC symbols in shared object. * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise. ld/ PR ld/19784 * testsuite/ld-i386/i386.exp: Remove pr19636-2e-nacl test. * testsuite/ld-i386/pr19636-2e-nacl.d: Moved to ... * testsuite/ld-i386/pr19636-2e.d: Here. Remove notarget. * testsuite/ld-ifunc/ifunc.exp: Run PR ld/19784 tests. * testsuite/ld-ifunc/pass.out: New file. * testsuite/ld-ifunc/pr19784a.c: Likewise. * testsuite/ld-ifunc/pr19784b.c: Likewise. * testsuite/ld-ifunc/pr19784c.c: Likewise.
Fixed for 2.27.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=74437ea28fb611d4c88077b486fd7c0a8b4c2a25 commit 74437ea28fb611d4c88077b486fd7c0a8b4c2a25 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Aug 29 08:12:59 2016 -0700 i386: Issue an error on non-PIC call to IFUNC in PIC object On i386, IFUNC function must be called via PLT. Since PLT in PIC object uses EBX register, R_386_PLT32 relocation must be used to call IFUNC function even when IFUNC function is defined locally. Linker should issue an error when R_386_PC32 relocation is used to call IFUNC function. Since PR ld/19784 tests doesn't use PLT relocation to local IFUNC function, they are moved to the x86-64 test directory. bfd/ PR ld/14961 PR ld/20515 * elf32-i386.c (elf_i386_check_relocs): Issue an error when R_386_PC32 relocation is used to call IFUNC function in PIC object. ld/ PR ld/14961 PR ld/20515 * testsuite/ld-i386/i386.exp: Run pr20515. * testsuite/ld-i386/pr20515.d: New file. * testsuite/ld-i386/pr20515.s: Likewise. * testsuite/ld-ifunc/ifunc-14a.s: Use R_386_PLT32 to call IFUNC function. * testsuite/ld-ifunc/ifunc-14c.s: Likewise. * testsuite/ld-ifunc/ifunc-2-i386.s: Likewise. * testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise. * testsuite/ld-ifunc/ifunc.exp: Move PR ld/19784 tests to ... * testsuite/ld-x86-64/x86-64.exp: Here. * testsuite/ld-ifunc/pr19784a.c: Moved to ... * testsuite/ld-x86-64/pr19784a.c: Here. * testsuite/ld-ifunc/pr19784b.c: Moved to ... * testsuite/ld-x86-64/pr19784b.c: Here. * testsuite/ld-ifunc/pr19784c.c: Moved to ... * testsuite/ld-x86-64/pr19784c.c: Here.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3c4f32287f2271ee46cf57669f867b39f716fe46 commit 3c4f32287f2271ee46cf57669f867b39f716fe46 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Aug 29 09:09:14 2016 -0700 Run PR ld/19784 tests only if ifunc attribute works * testsuite/ld-x86-64/x86-64.exp: Run PR ld/19784 tests only if ifunc attribute works.