bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/2870] New: X86_64: thread-local access via extern requires __thr


From: gary at intrepid dot com
Subject: [Bug ld/2870] New: X86_64: thread-local access via extern requires __thread
Date: 30 Jun 2006 17:50:52 -0000

A C program that references external data via an 'extern' fails to link, when 
the data is defined as thread-local in a separately compiled file, on an 
x86_64 (Opteron, Fedora Core 5) platform.

For example,

==> file1.c <==
extern int x;
 
int main() {
x = 5;
}
 
==> file2.c <==
int __thread x = 10;

------

% gcc file2.c file1.c
/usr/bin/ld: x: TLS definition in /tmp/ccOzkuFX.o section .tdata mismatches 
non-TLS reference in /tmp/cc1AhtnT.o
/tmp/cc1AhtnT.o: could not read symbols: Bad value
collect2: ld returned 1 exit status

------

The example will compile and link properly with the addition of __thread to 
the extern declaration above.

IMO, the user should not have to specify __thread on the extern declaration 
because the location of the data (section and relocation type) should be 
defined only at the point the data item is declared.

Note that this example (without the additions of __thread) will compile and 
link as is, on an IA64 platform.

(GNU ld version 2.16.91.0.6 20060212)

-- 
           Summary: X86_64: thread-local access via extern requires __thread
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: gary at intrepid dot com
                CC: bug-binutils at gnu dot org
  GCC host triplet: x86_64-unknown-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=2870

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]