Description of problem: Compiling this little program as a PIE leads to problems on x86-64: $ cat w.c __thread int a; int main(void) { return a; } Using gcc -o w -g -O2 -pie -fpie w.c one sees /usr/bin/ld: /tmp/ccU3JvLp.o: relocation R_X86_64_TPOFF32 against `a' can not be used when making a shared object; recompile with -fPIC It works with "-fpic -ftls-model=initial-exec", but not with "-fpic -ftls-model=local-exec". Based on http://sourceware.org/bugzilla/show_bug.cgi?id=10434 and the two-line patch there (http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&r1=1.178&r2=1.179), it's a simple mistake where the linker allows local-exec only for non-PIC (!info->shared) instead of testing for executable vs shared (info->executable). Version-Release number of selected component (if applicable): binutils-2.17.50.0.6-14.el5 How reproducible: 100% Steps to Reproduce: 1. See above. Actual results: Binaries that use TLS cannot be hardened with PIE. Expected results: Hardened binaries can use TLS. Additional info: Reproduced with QEMU 1.0-rc3.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2012-0271.html