bash-3.1$ cat t.c __thread int x; int _start () { return x; } bash-3.1$ make cc -fPIC -ftls-model=local-dynamic -c -o t.o t.c ./ld -o foo t.o nm -u foo U _GLOBAL_OFFSET_TABLE_ U __tls_get_addr bash-3.1$ The problem is there is /* LD->LE transition: Ensure it is: leaq foo@tlsld(%rip), %rdi; call __tls_get_addr@plt. We change it into: .word 0x6666; .byte 0x66; movl %fs:0, %rax. */ in elf64-x86-64.c. When the reference to __tls_get_addr is removed, it leaves undefined symbol in symtab. It is confusing.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d983c8c5503d680c6d4955ceb610a9beebc64460 commit d983c8c5503d680c6d4955ceb610a9beebc64460 Author: Alan Modra <amodra@gmail.com> Date: Wed Feb 18 17:02:39 2015 +1030 Strip undefined symbols from .symtab bfd/ PR ld/4317 * elflink.c (elf_link_input_bfd): Drop undefined local syms. (elf_link_output_extsym): Drop local and global undefined syms. Tidy. Expand comment. ld/testsuite/ PR ld/4317 * ld-aarch64/gc-tls-relocs.d, * ld-cris/locref2.d, * ld-elf/ehdr_start-weak.d, * ld-elf/group1.d, * ld-i386/compressed1.d, * ld-ia64/error1.d, * ld-ia64/error2.d, * ld-ia64/error3.d, * ld-mips-elf/pic-and-nonpic-1.nd, * ld-mmix/undef-3.d, * ld-powerpc/tlsexe.r, * ld-powerpc/tlsexetoc.r, * ld-powerpc/tlsso.r, * ld-powerpc/tlstocso.r, * ld-x86-64/compressed1.d, * ld-x86-64/pie1.d: Update.
Fixed
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=db95bb7c5946a109e1584ab2c43c052ff39e63bd commit db95bb7c5946a109e1584ab2c43c052ff39e63bd Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 19 04:45:27 2015 -0800 Use nm/readelf with "failif" PR ld/4317 * ld-i386/compressed1.d: Use nm/readelf with "failif". * ld-x86-64/compressed1.d: Likewise. * ld-x86-64/pie1.d: Likewise.
The binutils-2_26-branch branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a82e3ef7ad90d9335c8f3801f06916ffed43327b commit a82e3ef7ad90d9335c8f3801f06916ffed43327b Author: Alan Modra <amodra@gmail.com> Date: Thu Jan 14 19:02:18 2016 +1030 Revert "Strip undefined symbols from .symtab" This reverts commit d983c8c5503d680c6d4955ceb610a9beebc64460 and db95bb7c5946a109e1584ab2c43c052ff39e63bd The PR4317 patch introduced a ppc64le linux kernel build problem. PR ld/19421 PR ld/4317 bfd/ * elflink.c (elf_link_input_bfd): Revert 2015-02-19 changes. (elf_link_output_extsym): Likewise. ld/ * ld-aarch64/gc-tls-relocs.d: Revert 2015-02-19 changes. * ld-cris/locref2.d: Likewise. * ld-elf/ehdr_start-weak.d: Likewise. * ld-elf/group1.d: Likewise. * ld-i386/compressed1.d: Likewise. * ld-ia64/error1.d: Likewise. * ld-ia64/error2.d: Likewise. * ld-ia64/error3.d: Likewise. * ld-mips-elf/pic-and-nonpic-1.nd: Likewise. * ld-mmix/undef-3.d: Likewise. * ld-powerpc/tlsexe.r: Likewise. * ld-powerpc/tlsexetoc.r: Likewise. * ld-powerpc/tlsso.r: Likewise. * ld-powerpc/tlstocso.r: Likewise. * ld-x86-64/compressed1.d: Likewise. * ld-x86-64/pie1.d: Likewise.