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


R_X86_64_TPOFF32 is the correct relocation to use for non-PIC binaries but PIEs
must be PIC.  It's probably just a simple mistake where instead of testing for
PIC vs non-PIC the test checks for executable vs DSO.

This is no regression.  It also exists in gcc 4.1 (the oldest version available
here).


-- 
           Summary: TLS and PIE don't mix on x86-64
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drepper at redhat dot com
  GCC host triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34475

Reply via email to