frame.h: Update some comments.
authorH.J. Lu <hjl@gnu.org>
Sat, 27 Feb 1999 22:21:58 +0000 (22:21 +0000)
committerJeff Law <law@gcc.gnu.org>
Sat, 27 Feb 1999 22:21:58 +0000 (15:21 -0700)
        * frame.h: Update some comments.
        * defaults.h (TARGET_ATTRIBUTE_WEAK): Define.
        * crtstuff.c (__register_frame_info, __deregister_frame_info): Declare
        using TARGET_WEAK_ATTRIBUTE.
        (__do_global_dtors_aux): Check if __deregister_frame_info is
        zero before calling it.
        (__do_global_dtors): Likewise.
        (frame_dummy): Check if __register_frame_info is zero before
        calling it.
        (__frame_dummy): Likewise.

Co-Authored-By: Jeffrey A Law <law@cygnus.com>
From-SVN: r25487

gcc/ChangeLog
gcc/crtstuff.c
gcc/defaults.h
gcc/frame.h

index 47f379611d988bb626e28963431eab72face4cad..93871bcd44508afed9f7441d0f9784068e9cf5ab 100644 (file)
@@ -1,3 +1,17 @@
+Sat Feb 27 22:48:38 1999  H.J. Lu  (hjl@gnu.org)
+                         Jeffrey A Law  (law@cygnus.com)
+
+       * frame.h: Update some comments.
+       * defaults.h (TARGET_ATTRIBUTE_WEAK): Define.
+       * crtstuff.c (__register_frame_info, __deregister_frame_info): Declare
+       using TARGET_WEAK_ATTRIBUTE.
+       (__do_global_dtors_aux): Check if __deregister_frame_info is
+       zero before calling it.
+       (__do_global_dtors): Likewise.
+       (frame_dummy): Check if __register_frame_info is zero before
+       calling it.
+       (__frame_dummy): Likewise.
+
 Sat Feb 27 19:18:24 1999  Jeffrey A Law  (law@cygnus.com)
 
        * SERVICE: Update from the FSF.
index ce2c9561e64e287f961e8dc813f914f6ab475279..b7a482a6808a023196f4efd5cb8ee9d3a4df4000 100644 (file)
@@ -56,6 +56,34 @@ Boston, MA 02111-1307, USA.  */
 #include <stddef.h>
 #include "frame.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
+   symbols to be weak as well.
+
+   This exposes a core issue, how to handle creating weak references vs
+   how to create weak definitions.  Either we have to have the definition
+   of TARGET_WEAK_ATTRIBUTE be conditional in the shared header files or
+   have a second declaration if we want a function's references to be weak,
+   but not its definition.
+
+   Making TARGET_WEAK_ATTRIBUTE conditional seems like a good solution until
+   one thinks about scaling to larger problems -- ie, the condition under
+   which TARGET_WEAK_ATTRIBUTE is active will eventually get far too
+   complicated.
+
+   So, we take an approach similar to #pragma weak -- we have a second
+   declaration for functions that we want to have weak references.
+
+   Neither way is particularly good.  */
+   
+/* 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 *)
+                                 TARGET_ATTRIBUTE_WEAK;
+
+extern void *__deregister_frame_info (void *)
+                                    TARGET_ATTRIBUTE_WEAK;
+
 #ifndef OBJECT_FORMAT_MACHO
 
 /* Provide default definitions for the pseudo-ops used to switch to the
@@ -144,7 +172,8 @@ __do_global_dtors_aux ()
     }
 
 #ifdef EH_FRAME_SECTION_ASM_OP
-  __deregister_frame_info (__EH_FRAME_BEGIN__);
+  if (__deregister_frame_info)
+    __deregister_frame_info (__EH_FRAME_BEGIN__);
 #endif
   completed = 1;
 }
@@ -172,7 +201,8 @@ static void
 frame_dummy ()
 {
   static struct object object;
-  __register_frame_info (__EH_FRAME_BEGIN__, &object);
+  if (__register_frame_info)
+    __register_frame_info (__EH_FRAME_BEGIN__, &object);
 }
 
 static void __attribute__ ((__unused__))
@@ -256,7 +286,8 @@ __do_global_dtors ()
     (*p) ();
 
 #ifdef EH_FRAME_SECTION_ASM_OP
-  __deregister_frame_info (__EH_FRAME_BEGIN__);
+  if (__deregister_frame_info)
+    __deregister_frame_info (__EH_FRAME_BEGIN__);
 #endif
 }
 
@@ -268,7 +299,8 @@ void
 __frame_dummy ()
 {
   static struct object object;
-  __register_frame_info (__EH_FRAME_BEGIN__, &object);
+  if (__register_frame_info)
+    __register_frame_info (__EH_FRAME_BEGIN__, &object);
 }
 #endif
 #endif
index 0fbf2b92af84e74015699900251e84e6a67bc76a..a0e3bfca57acacd3b64057cb3bf354c3d1fe3c92 100644 (file)
@@ -133,6 +133,22 @@ do { fprintf (FILE, "\t%s\t", ASM_LONG);                           \
 #endif
 #endif
 
+/* If the target supports weak symbols, define TARGET_ATTRIBUTE_WEAK to
+   provide a weak attribute.  Else define it to nothing. 
+
+   This would normally belong in gansidecl.h, but SUPPORTS_WEAK is
+   not available at that time.
+
+   Note, this is only for use by target files which we know are to be
+   compiled by GCC.  */
+#ifndef TARGET_ATTRIBUTE_WEAK
+# if SUPPORTS_WEAK
+#  define TARGET_ATTRIBUTE_WEAK __attribute__ ((weak))
+# else
+#  define TARGET_ATTRIBUTE_WEAK
+# endif
+#endif
+
 /* If we have a definition of INCOMING_RETURN_ADDR_RTX, assume that
    the rest of the DWARF 2 frame unwind support is also provided.  */
 #if !defined (DWARF2_UNWIND_INFO) && defined (INCOMING_RETURN_ADDR_RTX)
index 1ae0dea5955cc45cb07aa56f4066329597832b32..985416cd1807c227424bd8b6d6d98e65785292c0 100644 (file)
@@ -54,6 +54,11 @@ 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 *);