[LLVMbugs] [Bug 22083] New: Clang fails to link program with extern address-taken initial-exec thread-local variable

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jan 2 18:24:21 PST 2015


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

            Bug ID: 22083
           Summary: Clang fails to link program with extern address-taken
                    initial-exec thread-local variable
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vonosmas at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ cat tmp/a.h 
__attribute__((tls_model("initial-exec")))
extern __thread unsigned long a;

$ cat tmp/a.cc 
#include "a.h"
int main() {
  return (unsigned long)(&a) % sizeof(a);
}

$ cat tmp/b.cc 
#include "a.h"
__thread unsigned long a;

$ ./bin/clang++ tmp/a.cc -c -o a.o ; ./bin/clang++ tmp/b.cc -c -o b.o ;
./bin/clang++ a.o b.o -o a.out ; ./a.out ; echo $?
/usr/bin/ld: a.o: TLS transition from R_X86_64_GOTTPOFF to R_X86_64_TPOFF32
against `a' at 0xd in section `.text' failed
/usr/bin/ld: final link failed: Bad value

Note that this example links and runs successfully if I use GCC or Clang 3.5

-- 
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/20150103/28a86f18/attachment.html>


More information about the llvm-bugs mailing list