A patch for libgcc runtime.h

H . J . Lu hjl@valinux.com
Mon Jul 31 10:53:00 GMT 2000


Hi, Jason,

Here is the patch with modications you suggested.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---
2000-07-31  H.J. Lu  (hjl@gnu.org)

	* runtime.h: New. The header file for the libgcc runtime ABI.

	* Makefile.in (USER_H): Add $(srcdir)/runtime.h.

	* frame.h (__register_frame): Moved to runtime.h.
	(__register_frame_table): Likewise.
	(__register_frame_table): Likewise.
	(__deregister_frame): Likewise.
	(__register_frame_info): Likewise.
	(__register_frame_info_table): Likewise.
	(__deregister_frame_info): Likewise.

	* frame.c: Include "assert.h" and "runtime.h".
	(__register_frame): Pass "struct object_buffer *" instead of
	"struct object *" to __register_frame_info ().
	(__register_frame_info): Take "struct object_buffer *" instead of
	"struct object *".
	(__register_frame_info_table): Likewise.

	* crtstuff.c: Include "runtime.h" instead of "frame.h".
	(__register_frame_info): Take "struct object_buffer *" instead of
	"struct object *".
	(fini_dummy): Pass "struct object_buffer *" instead of
	"struct object *" to __register_frame_info ().
	(__frame_dummy): Likewise.
	(__reg_frame_ctor): Likewise.

	* collect2.c (write_c_file_stat): Include "runtime.h" and pass
	"struct object_buffer *" instead of "struct object *" to
	__register_frame_info_table ().
	(write_c_file_glob): Likewise.

	* libgcc2.c: Include "runtime.h" instead of "frame.h".
	(__do_global_ctors): Pass "struct object_buffer *" instead of
	"struct object *" to __register_frame_info ().

Index: gcc/crtstuff.c
===================================================================
RCS file: /work/cvs/gnu/egcs/gcc/crtstuff.c,v
retrieving revision 1.1.1.16
diff -u -p -r1.1.1.16 crtstuff.c
--- gcc/crtstuff.c	2000/05/16 19:51:24	1.1.1.16
+++ gcc/crtstuff.c	2000/07/05 15:53:39
@@ -60,7 +60,7 @@ Boston, MA 02111-1307, USA.  */
 #include "tsystem.h"
 
 #include "defaults.h"
-#include "frame.h"
+#include "runtime.h"
 
 /* We do not want to add the weak attribute to the declarations of these
    routines in frame.h because that will cause the definition of these
@@ -84,7 +84,7 @@ Boston, MA 02111-1307, USA.  */
    
 /* References to __register_frame_info and __deregister_frame_info should
    be weak in this file if at all possible.  */
-extern void __register_frame_info (void *, struct object *)
+extern void __register_frame_info (void *, struct object_buffer *)
 				  TARGET_ATTRIBUTE_WEAK;
 
 extern void *__deregister_frame_info (void *)
@@ -228,7 +228,7 @@ fini_dummy (void)
 static void
 frame_dummy (void)
 {
-  static struct object object;
+  static struct object_buffer object;
   if (__register_frame_info)
     __register_frame_info (__EH_FRAME_BEGIN__, &object);
 }
@@ -327,7 +327,7 @@ __do_global_dtors (void)
 void
 __frame_dummy (void)
 {
-  static struct object object;
+  static struct object_buffer object;
   if (__register_frame_info)
     __register_frame_info (__EH_FRAME_BEGIN__, &object);
 }
@@ -552,7 +552,7 @@ static void __reg_frame_ctor (void) __at
 static void
 __reg_frame_ctor (void)
 {
-  static struct object object;
+  static struct object_buffer object;
   const struct section *eh_frame;
 
   eh_frame = getsectbynamefromheader (&_mh_execute_header,
Index: gcc/collect2.c
===================================================================
RCS file: /work/cvs/gnu/egcs/gcc/collect2.c,v
retrieving revision 1.1.1.44
diff -u -p -r1.1.1.44 collect2.c
--- gcc/collect2.c	2000/06/25 15:56:00	1.1.1.44
+++ gcc/collect2.c	2000/07/05 15:56:59
@@ -1945,21 +1945,10 @@ write_c_file_stat (stream, name)
       write_list (stream, "\t\t&", frame_tables.first);
       fprintf (stream, "\t0\n};\n");
 
-      /* This must match what's in frame.h.  */
-      fprintf (stream, "struct object {\n");
-      fprintf (stream, "  void *pc_begin;\n");
-      fprintf (stream, "  void *pc_end;\n");
-      fprintf (stream, "  void *fde_begin;\n");
-      fprintf (stream, "  void *fde_array;\n");
-      fprintf (stream, "  __SIZE_TYPE__ count;\n");
-      fprintf (stream, "  struct object *next;\n");
-      fprintf (stream, "};\n");
+      fprintf (stream, "#include <runtime.h>\n");
 
-      fprintf (stream, "extern void __register_frame_info_table (void *, struct object *);\n");
-      fprintf (stream, "extern void *__deregister_frame_info (void *);\n");
-
       fprintf (stream, "static void reg_frame () {\n");
-      fprintf (stream, "\tstatic struct object ob;\n");
+      fprintf (stream, "\tstatic struct object_buffer ob;\n");
       fprintf (stream, "\t__register_frame_info_table (frame_table, &ob);\n");
       fprintf (stream, "\t}\n");
 
@@ -2031,22 +2020,11 @@ write_c_file_glob (stream, name)
       fprintf (stream, "\tstatic void *frame_table[] = {\n");
       write_list (stream, "\t\t&", frame_tables.first);
       fprintf (stream, "\t0\n};\n");
-
-      /* This must match what's in frame.h.  */
-      fprintf (stream, "struct object {\n");
-      fprintf (stream, "  void *pc_begin;\n");
-      fprintf (stream, "  void *pc_end;\n");
-      fprintf (stream, "  void *fde_begin;\n");
-      fprintf (stream, "  void *fde_array;\n");
-      fprintf (stream, "  __SIZE_TYPE__ count;\n");
-      fprintf (stream, "  struct object *next;\n");
-      fprintf (stream, "};\n");
 
-      fprintf (stream, "extern void __register_frame_info_table (void *, struct object *);\n");
-      fprintf (stream, "extern void *__deregister_frame_info (void *);\n");
+      fprintf (stream, "#include <runtime.h>\n");
 
       fprintf (stream, "static void reg_frame () {\n");
-      fprintf (stream, "\tstatic struct object ob;\n");
+      fprintf (stream, "\tstatic struct object_buffer ob;\n");
       fprintf (stream, "\t__register_frame_info_table (frame_table, &ob);\n");
       fprintf (stream, "\t}\n");
 
Index: gcc/libgcc2.c
===================================================================
RCS file: /work/cvs/gnu/egcs/gcc/libgcc2.c,v
retrieving revision 1.1.1.45
diff -u -p -r1.1.1.45 libgcc2.c
--- gcc/libgcc2.c	2000/06/27 14:39:04	1.1.1.45
+++ gcc/libgcc2.c	2000/07/05 15:59:36
@@ -2794,7 +2794,7 @@ cacheflush (char *beg, int size, int fla
    code to run constructors.  In that case, we need to handle EH here, too.  */
 
 #ifdef EH_FRAME_SECTION
-#include "frame.h"
+#include "runtime.h"
 extern unsigned char __EH_FRAME_BEGIN__[];
 #endif
 
@@ -2834,7 +2834,7 @@ __do_global_ctors (void)
 {
 #ifdef EH_FRAME_SECTION
   {
-    static struct object object;
+    static struct object_buffer object;
     __register_frame_info (__EH_FRAME_BEGIN__, &object);
   }
 #endif
Index: gcc/frame.h
===================================================================
RCS file: /work/cvs/gnu/egcs/gcc/frame.h,v
retrieving revision 1.1.1.9
diff -u -p -r1.1.1.9 frame.h
--- gcc/frame.h	2000/07/04 18:56:08	1.1.1.9
+++ gcc/frame.h	2000/07/05 16:07:24
@@ -66,29 +66,6 @@ struct object {
   struct object *next;
 };
 
-/* Note the following routines are exported interfaces from libgcc; do not
-   change these interfaces.  Instead create new interfaces.  Also note
-   references to these functions may be made weak in files where they
-   are referenced.  */
-
-extern void __register_frame (void * );
-extern void __register_frame_table (void *);
-extern void __deregister_frame (void *);
-
-/* Called either from crtbegin.o or a static constructor to register the
-   unwind info for an object or translation unit, respectively.  */
-
-extern void __register_frame_info (void *, struct object *);
-
-/* Similar, but BEGIN is actually a pointer to a table of unwind entries
-   for different translation units.  Called from the file generated by
-   collect2.  */
-extern void __register_frame_info_table (void *, struct object *);
-
-/* Called from crtend.o to deregister the unwind info for an object.  */
-
-extern void *__deregister_frame_info (void *);
-
 /* Called from __throw to find the registers to restore for a given
    PC_TARGET.  The caller should allocate a local variable of `struct
    frame_state' (declared in frame.h) and pass its address to STATE_IN.
Index: gcc/frame.c
===================================================================
RCS file: /work/cvs/gnu/egcs/gcc/frame.c,v
retrieving revision 1.1.1.20
diff -u -p -r1.1.1.20 frame.c
--- gcc/frame.c	2000/06/08 23:24:44	1.1.1.20
+++ gcc/frame.c	2000/07/05 16:08:30
@@ -29,6 +29,9 @@ along with GNU CC; see the file COPYING.
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#include "runtime.h"
+#include "assert.h"
+
 /* Sorting an array of FDEs by address.
    (Ideally we would have the linker sort the FDEs so we don't have to do
    it at run time. But the linkers are not yet prepared for this.)  */
@@ -244,8 +247,12 @@ end_fde_sort (fde_accumulator *accu, siz
 /* Called from crtbegin.o to register the unwind info for an object.  */
 
 void
-__register_frame_info (void *begin, struct object *ob)
+__register_frame_info (void *begin, struct object_buffer *o)
 {
+  struct object *ob = (struct object *) o;
+
+  assert (sizeof (struct object_buffer) >= sizeof (struct object));
+
   ob->fde_begin = begin;
 
   ob->pc_begin = ob->pc_end = 0;
@@ -264,7 +271,8 @@ __register_frame_info (void *begin, stru
 void
 __register_frame (void *begin)
 {
-  struct object *ob = (struct object *) malloc (sizeof (struct object));
+  struct object_buffer *ob =
+    (struct object_buffer *) malloc (sizeof (struct object_buffer));
   __register_frame_info (begin, ob);                       
 }
 
@@ -273,8 +281,12 @@ __register_frame (void *begin)
    collect2.  */
 
 void
-__register_frame_info_table (void *begin, struct object *ob)
+__register_frame_info_table (void *begin, struct object_buffer *o)
 {
+  struct object *ob = (struct object *) o;
+
+  assert (sizeof (struct object_buffer) >= sizeof (struct object));
+
   ob->fde_begin = begin;
   ob->fde_array = begin;
 
--- gcc/Makefile.in.runtime	Wed Jul  5 09:10:43 2000
+++ gcc/Makefile.in	Wed Jul  5 09:11:41 2000
@@ -153,6 +153,7 @@ INSTALL_HEADERS_DIR = @build_install_hea
 USER_H = $(srcdir)/ginclude/stdarg.h $(srcdir)/ginclude/stddef.h \
     $(srcdir)/ginclude/varargs.h $(srcdir)/ginclude/proto.h \
     $(srcdir)/ginclude/stdbool.h $(srcdir)/ginclude/iso646.h \
+    $(srcdir)/runtime.h \
     $(EXTRA_HEADERS) $(LANG_EXTRA_HEADERS)
 
 # Target to use whe installing assert.h.  Some systems may
--- /dev/null	Fri Jul 21 07:29:28 2000
+++ gcc/runtime.h	Mon Jul 31 10:48:50 2000
@@ -0,0 +1,30 @@
+#ifndef __RUNTIME_H
+#define __RUNTIME_H 1
+
+struct object_buffer
+{
+  /* FIXME: Is it large enough for future new targets? */
+  void * dummy [16];
+};
+
+/* Note the following routines are exported interfaces from libgcc; do
+   not change these interfaces.  Instead create new interfaces.  Also
+   note references to these functions may be made weak in files where
+   they are referenced.  */
+
+/* Called either from crtbegin.o or a static constructor to register the
+   unwind info for an object or translation unit, respectively.  */
+
+extern void __register_frame_info (void *, struct object_buffer *);
+
+/* Similar, but BEGIN is actually a pointer to a table of unwind
+   entries for different translation units.  Called from the file
+   generated by collect2.  */
+
+extern void __register_frame_info_table (void *, struct object_buffer *);
+
+/* Called from crtend.o to deregister the unwind info for an object.  */
+
+extern void *__deregister_frame_info (void *);
+
+#endif /* __RUNTIME_H */


More information about the Gcc-patches mailing list