[mathieu@mathieu-laptop elf-loader]$ ld --version GNU ld version 2.19.51.0.2-17.fc11 20090204 [mathieu@mathieu-laptop test]$ gcc -dumpmachine x86_64-redhat-linux [mathieu@mathieu-laptop test]$ gcc --version gcc (GCC) 4.4.0 20090506 (Red Hat 4.4.0-4) [mathieu@mathieu-laptop test]$ uname -a Linux mathieu-laptop 2.6.29.5-191.fc11.x86_64 #1 SMP Tue Jun 16 23:23:21 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux testcase: [mathieu@mathieu-laptop test]$ cat >test.c __thread int g_a; int main (int argc, char *argv[]) { g_a = 0; return 0; } [mathieu@mathieu-laptop test]$ gcc -fpie -pie ./test.c -o test /usr/bin/ld: /tmp/ccsIE4YR.o: relocation R_X86_64_TPOFF32 against `g_a' can not be used when making a shared object; recompile with -fPIC /tmp/ccsIE4YR.o: could not read symbols: Bad value collect2: ld returned 1 exit status The above works with "gcc -fpic -pie ./test.c -o test" (which, I know, is not really supported).
Note: this all appears to come from tls model local-exec. i.e., if I specify a different tls model with __attribute__((tls_model("global-dynamic"))), the linker does generate the above-mentionned error
(In reply to comment #1) > Note: this all appears to come from tls model local-exec. i.e., if I specify a > different tls model with __attribute__((tls_model("global-dynamic"))), the > linker does generate the above-mentionned error s/does generate/does not generate/
Subject: Bug 10434 CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2009-07-23 21:22:20 Modified files: bfd : ChangeLog elf64-x86-64.c ld/testsuite : ChangeLog ld/testsuite/ld-x86-64: x86-64.exp Added files: ld/testsuite/ld-x86-64: tlsle1.d tlsle1.s Log message: bfd/ 2009-07-23 H.J. Lu <hongjiu.lu@intel.com> PR ld/10434 * elf64-x86-64.c (elf64_x86_64_check_relocs): Check executable instead of shared for R_X86_64_TPOFF32. (elf64_x86_64_relocate_section): Likewise. ld/testsuite/ 2009-07-23 H.J. Lu <hongjiu.lu@intel.com> PR ld/10434 * ld-x86-64/tlsle1.d: New. * ld-x86-64/tlsle1.s: Likewise. * ld-x86-64/x86-64.exp: Run tlsle1. Patches: http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.4699&r2=1.4700 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&r1=1.178&r2=1.179 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1132&r2=1.1133 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlsle1.d.diff?cvsroot=src&r1=NONE&r2=1.1 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlsle1.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/x86-64.exp.diff?cvsroot=src&r1=1.11&r2=1.12
Fixed.