This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

Re: c++/3099: cygwin: Many g++ EH failures


On Wed, Jun 13, 2001 at 11:20:41AM -0400, Christopher Faylor wrote:
> If you can give me a clue about how to do this, I'll take a stab at it.

I think I've got a handle on it.

There are actually two solutions, one which can be done within 
gcc alone and does not require cygwin changes.  But I think it's
slightly cleaner to handle it in the same place as constructors,
which would be cygwin proper.

Anyway, the cygwin patch (not yet tested) follows.  The gcc patch
would incorporate crtbegin.S and crtend.c (manually tested) are
also reproduced below.

Oh, damn.  I forgot about dll symbol resolution rules.  This will
only work for applications until libgcc_s is built as a dll, since
there can be only one live copy of the exception handling code.
So unless that's addressed shortly, reverting to sjlj may be easiest.


r~
Index: ld/scripttempl/pe.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/pe.sc,v
retrieving revision 1.4
diff -u -p -r1.4 pe.sc
--- pe.sc	2000/02/24 17:53:12	1.4
+++ pe.sc	2001/06/13 16:29:01
@@ -58,10 +58,7 @@ SECTIONS
     ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; 
 			LONG (-1); *(.dtors); *(.dtor);  LONG (0); }
     ${RELOCATING+ *(.fini)}
-    /* ??? Why is .gcc_exc here?  */
-    ${RELOCATING+ *(.gcc_exc)}
     ${RELOCATING+ etext = .;}
-    *(.gcc_except_table)
   }
 
   /* The Cygwin32 library uses a section to avoid copying certain data
@@ -84,7 +81,10 @@ SECTIONS
   {
     *(.rdata)
     ${R_RDATA}
-    *(.eh_frame)
+    ${RELOCATING+ ___EH_FRAME_BEGIN__ = .; __EH_FRAME_BEGIN__ = . ; 
+			*(.eh_frame); LONG (-1); }
+    /* ??? Why is .gcc_exc here?  */
+    ${RELOCATING+ *(.gcc_except_table) *(.gcc_exc)}
   }
 
   .pdata ${RELOCATING+BLOCK(__section_alignment__)} :
Index: winsup/cygwin/dcrt0.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dcrt0.cc,v
retrieving revision 1.96
diff -u -p -r1.96 dcrt0.cc
--- dcrt0.cc	2001/06/04 01:28:09	1.96
+++ dcrt0.cc	2001/06/13 16:36:49
@@ -119,6 +119,30 @@ char *old_title = NULL;
 char title_buf[TITLESIZE + 1];
 
 static void
+do_frame_cleanup (void)
+{
+  __deregister_frame_info (__EH_FRAME_BEGIN__);
+}
+
+static void
+do_frame_setup (void)
+{
+  /* ??? Can we include gcc/unwind-dw2-fde.h instead?  */
+  struct object
+  {
+    void *opaque[6];
+  };
+  extern "C" __register_frame_info (void *, struct object *);
+
+  static struct object obj;
+
+  __register_frame_info (__EH_FRAME_BEGIN__, &obj);
+
+  if (user_data->magic_biscuit == SIZEOF_PER_PROCESS)
+    atexit (do_frame_cleanup);
+}
+
+static void
 do_global_dtors (void)
 {
   if (user_data->dtors)
@@ -639,6 +663,7 @@ dll_crt0_1 ()
   /* Initialize SIGSEGV handling, etc. */
   init_exceptions (&cygwin_except_entry);
 
+  do_frame_setup ();
   do_global_ctors (&__CTOR_LIST__, 1);
 
   /* Set the os_being_run global. */
Index: winsup/cygwin/winsup.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/winsup.h,v
retrieving revision 1.57
diff -u -p -r1.57 winsup.h
--- winsup.h	2001/06/12 11:31:05	1.57
+++ winsup.h	2001/06/13 16:36:50
@@ -213,6 +213,7 @@ extern DWORD binmode;
 extern char _data_start__, _data_end__, _bss_start__, _bss_end__;
 extern void (*__CTOR_LIST__) (void);
 extern void (*__DTOR_LIST__) (void);
+extern char __EH_FRAME_BEGIN__[];
 extern SYSTEM_INFO system_info;
 };
 
.section	.eh_frame,"w"
.globl __EH_FRAME_BEGIN__
.globl ___EH_FRAME_BEGIN__
___EH_FRAME_BEGIN__:
__EH_FRAME_BEGIN__:
#include <stddef.h>
#include "unwind-dw2-fde.h"

extern char __EH_FRAME_BEGIN__[];
static struct object obj;

static int eh_frame_end __attribute__((section(".eh_frame"))) = -1;

static void __attribute__((constructor))
do_frame_setup (void)
{
  __register_frame_info (__EH_FRAME_BEGIN__, &obj);
}

static void __attribute__((destructor))
do_frame_cleanup (void)
{
  __deregister_frame_info (__EH_FRAME_BEGIN__);
}

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