bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/9923] New: ld crashes on Cygwin when __tls_used is seen but not


From: Moritz dot Kroll at gmx dot de
Subject: [Bug ld/9923] New: ld crashes on Cygwin when __tls_used is seen but not defined (testcase + patch)
Date: 4 Mar 2009 16:02:58 -0000

If you assemble and link the attached testcase thread-small.s on Cygwin 
(probably on MinGW, too):

$ ld -v
GNU ld (GNU Binutils) 2.18.50.20080625

$ as --32 thread-small.s -o thread-small.o
$ ld -Bdynamic --dll-search-prefix=cyg -o thread.exe /usr/lib/crt0.o -
L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -
L/usr/lib thread-small.o -lm -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -
lshell32 -lgcc
      5 [main] ld 4976 _cygtls::handle_exceptions: Error while dumping state 
(probably corrupted stack)
Segmentation fault (core dumped)

ld crashes with a segmentation fault in bfd/peXXigen.c:2354 because 
the "u.def" component of a bfd_link_hash_entry (include/bfdlink.h) is accessed 
without priorly checking the "type".
In the testcase, the symbol "__tls_used" is declared as a global symbol, but 
the definition is missing. Therefore the type of the bfd_link_hash_entry 
is "bfd_link_hash_undefined", thus "u.def" is invalid.

The attached patch adds a check for the type making sure "u.def" is valid. 
With this, the following error message is reported for the testcase, which is 
the expected result:

thread.exe: unable to fill in DataDictionary[9] because __tls_used is missing

-- 
           Summary: ld crashes on Cygwin when __tls_used is seen but not
                    defined (testcase + patch)
           Product: binutils
           Version: 2.20 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: Moritz dot Kroll at gmx dot de
                CC: bug-binutils at gnu dot org
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


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

------- 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]