This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC/Patch] : Enable Dwarf2 unwind on cygwin and mingw32


The attached patch enable Dwarf2 exception handling on windows32 tagets. 

It adds crtbegin.o and crtend.o as startfile/endfiles based on crtstuff
code, but separated out for now to allow easier specialization for a
system that does not have .init/.fini sections. 

On cygwin, __register and __deregister_frame_info are invoked indirectly
via a ctor/dtor pair. The ctor/dtor live in crtend to make them the
first ctor, last dtor invoked. The actual call to the unwind-dw2-fde.o
functions is done in crtbegin so that we can resolve the references in
libgcc.a. It is done using ctors/dtors to avoid having to depend on
changes to cygwin1.dll startup code.

On mingw32, we can use a more direct approach, by overriding the library,
__main and __do_globl_{c,d}tors functions with code in crtbegin. These
call the registration functions directly. I prefer this approach because
it absolutely makes sure that that the registration happens before
anything else.  I could live with using the cygwin ctor/dtor method
for mingw for the sake of simplification, if that is an issue. 

The removal of #define DWARF2_UNWIND_INFO 0 in cygming.h effectively
makes Dwarf2 unwind the default. It can still be overriden with
--enable-sjlj-exceptions when configuring.

The patch also enables the use of .jcr section to register Java classes.
This is guarded by USE_JCR_SECTION -- which actually belongs to another
patch for java/class.c, but is here to avoid using .jcr section until
better linker support is available. A binutils patch for this is
submitted at:

I have been using something very similar (sans .jcr) to this in my
"personal" builds of gcc since 3.2 days, but I do not use win32 API
functions that require callbacks in conjunction with C++ EH, so I have
not been hit by the problems with callbacks that at least one mingw user
has reported. The recent binutils patches to make weak symbols work on
PECOFF means that another objection to Dwarf2 on mingw user list -
unnecessary code bloat in absence of exception handling -- can now be

The patch would fix this PR:
The .jcr part is relevant to:

This patch produces no regressions wih mingw32 in C, C++, objc or
libjava testsuite. I have not tested Ada in a long time, but it used to
work there in 3.3. and 3.4.x

I would appreciate any comments on this -- and, even better, more extensive



2004-11-24  Danny Smith  <>

	* config.gcc (*-cygwin*): Add crtbegin.o, crtend.o as
	* config.gcc (*-mingw*): Likewise.
	* libgcc2.c (L__main): Do nothing for mingw32.
	* config/i386/cygming.h (DWARF2_UNWIND_INFO): Don't override
	* config/i386/cygwin.h (STARTFILE_SPEC): Add crtbegin.o.
	(ENDFILE_SPEC): Define as crtend.o.
	* config/i386/mingw32.h (STARTFILE_SEC): Add crtbegin.o.
	(ENDFILE_SPEC): Define as crtend.o.
	* config/i386/t-cygming: Add rules for crtbegin.o, crtend.o.
	* config/i386/cygming-crtbegin.c: New file.
	* config/i386/cygming-crtend.c: New file.

Find local movie times and trailers on Yahoo! Movies.

Attachment: cygming-dwarf2-eh.patch
Description: cygming-dwarf2-eh.patch

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]