[LLVMbugs] [Bug 17058] New: Shared library relocation R_X86_64_TPOFF32 with __thread

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Sep 2 08:48:27 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=17058

            Bug ID: 17058
           Summary: Shared library relocation R_X86_64_TPOFF32 with
                    __thread
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haael at interia.pl
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I don't know if the code is completely correct, but I get the following error
when trying to compile a shared library:

ld: /tmp/tsd-cGUFwW.o: relocation R_X86_64_TPOFF32 against `function.data' can
not be used when making a shared object; recompile with -fPIC

Of course, recompiling with -fPIC gives the same error.

The offending code is:
===========================

int function(void)
{
  static __thread int data __attribute__ ((tls_model ("initial-exec")));
  return data;
}

===========================

I compile it as a shared library:

clang -nostdlib -shared -fPIC file.c

Adding or removing the -fPIC option does nothing. Compiling as a normal
executable works. The code also works when I remove the final return of the
data, possibly because the variable is optimized away.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130902/6d50a8bb/attachment.html>


More information about the llvm-bugs mailing list