Why link C with crtstuff? [patch]

H.J. Lu hjl@lucon.org
Sun Apr 26 21:56:00 GMT 1998


> 
> > > > 
> > > > The patch is wrong. Please try this patch.
> > > > 
> > > Thanks. It works for all my primitive tests except one.
> > > I have a shared library compiled by gcc-2.8.1 (libvga-1.2.13, but this
> > > should not be important):
> > > 
> > 
> > Please try this one. BTW, it will only works on systems with crtbeginS.o
> > and crtendS.o.
> 
> It fails to apply to Makefile.in
> 
> > diff -u -r1.1.1.33 Makefile.in
> > --- Makefile.in	1998/04/26 16:06:39	1.1.1.33
> > +++ Makefile.in	1998/04/26 20:46:39
> >  s-crtS: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
> 
> No @@ here, patch (2.4) just skips this.

Ooops. Here is the new one.

> Also, it seems to be against a snapshot (there is no s-crtS in 1.0.2).

It is stamp-crtS in 1.0.2. Just apply it by hand for 1.0.2.

> Is it against the latest one?

Yes.


-- 
H.J. Lu (hjl@gnu.org)
---
Sun Apr 26 13:51:04 1998  H.J. Lu  (hjl@gnu.org)

	* crtstuff.c (__register_frame_info, __deregister_frame_info):
	If CRTSTUFFS_O is not defined and HANDLE_SYSV_PRAGMA is
	defined, make them weak and check if they are none-zero before
	calling them.

	* Makefile.in (crtbeginS.o crtendS.o): Add -fno-exceptions and
	-DCRTSTUFFS_O.

Index: crtstuff.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/gcc/crtstuff.c,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 crtstuff.c
--- crtstuff.c	1998/04/05 19:07:15	1.1.1.9
+++ crtstuff.c	1998/04/26 20:44:57
@@ -80,6 +80,11 @@
 #endif
 #if !defined (EH_FRAME_SECTION_ASM_OP) && defined (DWARF2_UNWIND_INFO) && defined(ASM_OUTPUT_SECTION_NAME)
 #define EH_FRAME_SECTION_ASM_OP	".section\t.eh_frame,\"aw\""
+
+#if !defined(CRTSTUFFS_O) && defined(HANDLE_SYSV_PRAGMA)
+#pragma weak __register_frame_info
+#pragma weak __deregister_frame_info
+#endif
 #endif
 
 #ifdef OBJECT_FORMAT_ELF
@@ -142,8 +147,11 @@
     }
 
 #ifdef EH_FRAME_SECTION_ASM_OP
-  __deregister_frame_info (__EH_FRAME_BEGIN__);
+#if !defined(CRTSTUFFS_O) && defined(HANDLE_SYSV_PRAGMA)
+  if (__deregister_frame_info)
 #endif
+    __deregister_frame_info (__EH_FRAME_BEGIN__);
+#endif
   completed = 1;
 }
 
@@ -170,7 +178,10 @@
 frame_dummy ()
 {
   static struct object object;
-  __register_frame_info (__EH_FRAME_BEGIN__, &object);
+#if !defined(CRTSTUFFS_O) && defined(HANDLE_SYSV_PRAGMA)
+  if (__register_frame_info)
+#endif
+    __register_frame_info (__EH_FRAME_BEGIN__, &object);
 }
 
 static void
@@ -254,8 +265,11 @@
     (*p) ();
 
 #ifdef EH_FRAME_SECTION_ASM_OP
-  __deregister_frame_info (__EH_FRAME_BEGIN__);
+#if !defined(CRTSTUFFS_O) && defined(HANDLE_SYSV_PRAGMA)
+  if (__deregister_frame_info)
 #endif
+    __deregister_frame_info (__EH_FRAME_BEGIN__);
+#endif
 }
 
 #ifdef EH_FRAME_SECTION_ASM_OP
@@ -266,7 +280,10 @@
 __frame_dummy ()
 {
   static struct object object;
-  __register_frame_info (__EH_FRAME_BEGIN__, &object);
+#if !defined(CRTSTUFFS_O) && defined(HANDLE_SYSV_PRAGMA)
+  if (__register_frame_info)
+#endif
+    __register_frame_info (__EH_FRAME_BEGIN__, &object);
 }
 #endif
 #endif
Index: Makefile.in
===================================================================
RCS file: /home/work/cvs/gnu/egcs/gcc/Makefile.in,v
retrieving revision 1.1.1.33
diff -u -r1.1.1.33 Makefile.in
--- Makefile.in	1998/04/26 16:06:39	1.1.1.33
+++ Makefile.in	1998/04/26 20:46:39
@@ -1196,12 +1198,12 @@
 s-crtS: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
   defaults.h frame.h gbl-ctors.h
 	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS_S) \
-	  -DCRT_BEGIN -finhibit-size-directive -fno-inline-functions \
-	  -g0 -c $(srcdir)/crtstuff.c 
+	  -DCRT_BEGIN -DCRTSTUFFS_O -finhibit-size-directive -fno-inline-functions \
+	  -fno-exceptions -g0 -c $(srcdir)/crtstuff.c 
 	mv crtstuff$(objext) crtbeginS$(objext)
 	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS_S) \
-	  -DCRT_END -finhibit-size-directive -fno-inline-functions \
-	  -g0 -c $(srcdir)/crtstuff.c -o crtendS$(objext)
+	  -DCRT_END -DCRTSTUFFS_O -finhibit-size-directive -fno-inline-functions \
+	  -fno-exceptions -g0 -c $(srcdir)/crtstuff.c -o crtendS$(objext)
 	touch s-crtS
 
 # Compile the start modules crt0.o and mcrt0.o that are linked with every program



More information about the Gcc mailing list