[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/2147] New: ctors from crtend.o not linked on linux cross gcc (__
From: |
Henry at BigFoot dot de |
Subject: |
[Bug ld/2147] New: ctors from crtend.o not linked on linux cross gcc (__cxa_throw) |
Date: |
12 Jan 2006 17:56:19 -0000 |
Cross compile from linux for mingw32 don't init the ctors from crtend.o!
Every 'throw' in a program crashes with a "NULL-Pointer read" in function
__cxa_throw.
>>> Source line: gcc-3.3.1-20030804-1/libstdc++-v3/libsupc++/eh_throw.cc:64 >>>
header->unexpectedHandler = __unexpected_handler;
<<< snip <<<
"__unexpected_handler" is a macro to variable "__w32_sharedptr_unexpected", and
there was not init. Internal function "_w32_sharedptr_initialize" was not
called before main starts.
This is the standard function tree, started from a section .ctors in crtend.o:
__reg_frame_ctor
__do_frame_init
__w32_sharedptr_initialize
__register_frame_info
Problem is, that "*crtend.o (.ctors)" in linker script does not include the
function pointer to "__reg_frame_ctor". With other words: The default linker
script from mingw32 not loads contructors from crtend.o.
>>> cat sample.cc >>>
int main(void)
{
try {
throw "End!";
} catch (...) {
return 1;
}
return 0;
}
<<< end cat <<<
Build it with linker map
i686-pc-mingw32-g++ -Wl,-M -Wl,--verbose -o sample.exe sample.cc
See the emtpy section .ctors for crtend.o:
>>> old bad map file >>>
0x00406c80 __CTOR_LIST__ = .
0x00406c80 0x4 LONG 0xffffffff
*(EXCLUDE_FILE(*crtend.o) .ctors)
*(.ctor)
*(SORT(.ctors.*))
*crtend.o(.ctors)
0x00406c84 0x4 LONG 0x0
0x00406c88 ___DTOR_LIST__ = .
<<< snip map <<<
With my patch shows good, for sample:
>>> new good map file >>>
0x00406c80 __CTOR_LIST__ = .
0x00406c80 0x4 LONG 0xffffffff
*(EXCLUDE_FILE(*crtend.o) .ctors)
*(.ctor)
*(SORT(.ctors.*))
*(.ctors)
.ctors 0x00406c84 0x4 /home/hn/CoLinux/mingw32/lib/gcc-lib/i686-
pc-mingw32/3.3.1/crtend.o
0x00406c88 0x4 LONG 0x0
0x00406c8c ___DTOR_LIST__ = .
<<< snip map <<<
>>> patch >>>
--- binutils-2.16.91-20050827-1/ld/scripttempl/pe.sc
+++ binutils-2.16.91-20050827-1/ld/scripttempl/pe.sc
@@ -70,14 +70,14 @@
*(EXCLUDE_FILE (*crtend.o) .ctors);
*(.ctor);
*(SORT(.ctors.*));
- *crtend.o (.ctors);
+ *(.ctors);
LONG (0); }
${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
LONG (-1);
*(EXCLUDE_FILE (*crtend.o) .dtors);
*(.dtor);
*(SORT(.dtors.*));
- *crtend.o (.dtors);
+ *(.dtors);
LONG (0); }
${RELOCATING+ *(.fini)}
/* ??? Why is .gcc_exc here? */
<<< end diff <<<
Same problem if using this versions:
binutils-2.16.91-20050827-1-src.tar.gz (is the last, I think)
gcc-g++-3.4.4-20050522-1-src.tar.gz
Patch for binutils-2.15.91:
https://sourceforge.net/tracker/download.php?
group_id=2435&atid=102435&file_id=161628&aid=1394022
Patch for binutils-2.16.91:
https://sourceforge.net/tracker/download.php?
group_id=2435&atid=102435&file_id=163126&aid=1394022
My project details can read here:
http://www.henrynestler.com/colinux/patches/devel/throw-readme.txt
--
Summary: ctors from crtend.o not linked on linux cross gcc
(__cxa_throw)
Product: binutils
Version: 2.16
Status: NEW
Severity: normal
Priority: P2
Component: ld
AssignedTo: unassigned at sources dot redhat dot com
ReportedBy: Henry at BigFoot dot de
CC: bug-binutils at gnu dot org
GCC build triplet: i686-pc-linux
GCC host triplet: i686-pc-linux
GCC target triplet: i686-pc-mingw32
http://sourceware.org/bugzilla/show_bug.cgi?id=2147
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
- [Bug ld/2147] New: ctors from crtend.o not linked on linux cross gcc (__cxa_throw),
Henry at BigFoot dot de <=