This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

[csl-arm] Use __aeabi_atext.


The patch below makes g++ use __aeabi_atexit rather than __cxa_atexit for 
registering static object destructors, as suggested by the new Arm EABI.

Tested on i686-linux and cross to arm-none-elf and arm-none-eabi.
Applied to csl-arm-brach.
I've also added it my queue of eabi patches for 4.1

Paul

2004-11-05  Paul Brook  <paul@codesourcery.com>

 * target-def.h (TARGET_CXX_ATEXIT_NAME): Define.
 (TARGET_CXX): Add TARGET_CXX_ATEXIT_NAME.
 * target.h (gcc_target): Add cxx.atexit_name.
 * targhooks.c (default_cxx_atexit_name): New function.
 * targhooks.h (default_cxx_atexit_name): Add prototype.
 * config/arm/arm.c (arm_cxx_atexit_name): New function.
 (TARGET_CXX_ATEXIT_NAME): Define.
 * cp/decl.c (get_atexit_node): Use targetm.cxx.atexit_name.
 * doc/tm.texi: Document TARGET_CXX_ATEXIT_NAME.

Index: gcc/target-def.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/target-def.h,v
retrieving revision 1.59.2.13
diff -u -p -r1.59.2.13 target-def.h
--- gcc/target-def.h 30 Sep 2004 19:48:43 -0000 1.59.2.13
+++ gcc/target-def.h 27 Oct 2004 23:26:41 -0000
@@ -402,6 +402,10 @@ Foundation, 59 Temple Place - Suite 330,
 #define TARGET_CXX_UNWIND_RESUME_NAME default_unwind_resume_name
 #endif
 
+#ifndef TARGET_CXX_ATEXIT_NAME
+#define TARGET_CXX_ATEXIT_NAME default_cxx_atexit_name
+#endif
+
 #define TARGET_CXX    \
   {      \
     TARGET_CXX_GUARD_TYPE,   \
@@ -411,7 +415,8 @@ Foundation, 59 Temple Place - Suite 330,
     TARGET_CXX_CDTOR_RETURNS_THIS,  \
     TARGET_CXX_KEY_METHOD_MAY_BE_INLINE, \
     TARGET_CXX_EXPORT_CLASS_DATA,   \
-    TARGET_CXX_UNWIND_RESUME_NAME  \
+    TARGET_CXX_UNWIND_RESUME_NAME,  \
+    TARGET_CXX_ATEXIT_NAME   \
   }
 
 /* The whole shebang.  */
Index: gcc/target.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/target.h,v
retrieving revision 1.67.2.15
diff -u -p -r1.67.2.15 target.h
--- gcc/target.h 30 Sep 2004 19:48:44 -0000 1.67.2.15
+++ gcc/target.h 27 Oct 2004 23:27:26 -0000
@@ -477,6 +477,9 @@ struct gcc_target
     /* Return the name of the function used to exit from a c++ cleanup
        handler.  */
     const char * (*unwind_resume_name) (void);
+    /* Returns the name of the function used to register static object
+       destructors.  */
+    const char * (*atexit_name) (void);
   } cxx;
 
   /* Leave the boolean fields at the end.  */
Index: gcc/targhooks.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/targhooks.c,v
retrieving revision 2.8.6.6
diff -u -p -r2.8.6.6 targhooks.c
--- gcc/targhooks.c	29 Sep 2004 16:08:35 -0000	2.8.6.6
+++ gcc/targhooks.c	27 Oct 2004 23:29:25 -0000
@@ -257,6 +257,15 @@ default_unwind_resume_name (void)
 }
 
 
+/* The ia64/generic C++ ABI defines __cxa_atexit.  */
+
+const char *
+default_cxx_atexit_name (void)
+{
+  return "__cxa_atexit";
+}
+
+
 /* Emit any directives required to unwind this instruction.  */
 
 void
Index: gcc/targhooks.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/targhooks.h,v
retrieving revision 2.3.6.6
diff -u -p -r2.3.6.6 targhooks.h
--- gcc/targhooks.h	29 Sep 2004 16:08:35 -0000	2.3.6.6
+++ gcc/targhooks.h	27 Oct 2004 23:28:07 -0000
@@ -40,5 +40,6 @@ extern bool hook_bool_machine_mode_true 
 extern tree default_cxx_guard_type (void);
 extern tree default_cxx_get_cookie_size (tree);
 extern const char * default_unwind_resume_name (void);
+extern const char * default_cxx_atexit_name (void);
 
 extern void default_unwind_emit (FILE *, rtx);
Index: gcc/config/arm/arm.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.303.2.60
diff -u -p -r1.303.2.60 arm.c
--- gcc/config/arm/arm.c	13 Oct 2004 12:49:28 -0000	1.303.2.60
+++ gcc/config/arm/arm.c	27 Oct 2004 23:30:08 -0000
@@ -172,6 +172,7 @@ static bool arm_cxx_cdtor_returns_this (
 static bool arm_cxx_key_method_may_be_inline (void);
 static bool arm_cxx_export_class_data (void);
 static const char * arm_cxx_unwind_resume_name (void);
+static const char * arm_cxx_atexit_name (void);
 static void arm_init_libfuncs (void);
 
 
@@ -288,6 +289,9 @@ static void arm_init_libfuncs (void);
 #undef TARGET_CXX_KEY_METHOD_MAY_BE_INLINE
 #define TARGET_CXX_KEY_METHOD_MAY_BE_INLINE arm_cxx_key_method_may_be_inline
 
+#undef TARGET_CXX_ATEXIT_NAME
+#define TARGET_CXX_ATEXIT_NAME arm_cxx_atexit_name
+
 #undef TARGET_CXX_EXPORT_CLASS_DATA
 #define TARGET_CXX_EXPORT_CLASS_DATA arm_cxx_export_class_data
 
@@ -14643,6 +14647,20 @@ arm_cxx_export_class_data (void)
   return TARGET_AAPCS_BASED;
 }
 
+
+/* The EABI wants us to use __aeabi_atexit for registering static object
+   destructors.  */
+
+static const char *
+arm_cxx_atexit_name (void)
+{
+  if (TARGET_AAPCS_BASED)
+    return "__aeabi_atexit";
+  else
+    return default_cxx_atexit_name ();
+}
+
+
 void
 arm_set_return_address (rtx source, rtx scratch)
 {
Index: gcc/cp/decl.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/cp/decl.c,v
retrieving revision 1.1150.2.14
diff -u -p -r1.1150.2.14 decl.c
--- gcc/cp/decl.c 30 Sep 2004 19:49:14 -0000 1.1150.2.14
+++ gcc/cp/decl.c 27 Oct 2004 23:24:48 -0000
@@ -5046,7 +5046,7 @@ get_atexit_node (void)
       /* And the final __cxa_atexit type.  */
       fn_type = build_function_type (integer_type_node, arg_types);
       fn_ptr_type = build_pointer_type (fn_type);
-      name = "__cxa_atexit";
+      name = targetm.cxx.atexit_name ();
     }
   else
     {
Index: gcc/doc/tm.texi
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/doc/tm.texi,v
retrieving revision 1.264.2.20
diff -u -p -r1.264.2.20 tm.texi
--- gcc/doc/tm.texi 30 Sep 2004 19:49:20 -0000 1.264.2.20
+++ gcc/doc/tm.texi 27 Oct 2004 23:24:48 -0000
@@ -8616,6 +8616,12 @@ This hook returns the name of the routin
 resume unwinding at the end of a C++ catch handler.
 @end deftypefn
 
+@deftypefn {Target Hook} const char * TARGET_CXX_ATEXIT_NAME (void)
+This hook returns teh name of the function to use for registering
+static destructors when -fuse-cxa-atexit is in effect.
+The dafault is @code{"__cxa_atexit"}.
+@end deftypefn
+
 @node Misc
 @section Miscellaneous Parameters
 @cindex parameters, miscellaneous


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