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] Fix __aeabi_atexit


When implementing the compiler bits of __aeabi_atexit I didn't notice that the 
argument list was different to that of __cxa_atexit.
The attached patch fixes this.

Tested with cross to arm-none-eabi.
Applied to csl-arm-branch.

Paul

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

 * target-def.h (TARGET_CXX_ATEXIT_NAME): Remove.
 (TARGET_CXX_USE_AEABI_ATEXIT): Define.
 * target.h (struct gcc_target): Remove cxx.atexit_name.
 Add cxx.use_aeabi_atexit.
 * targhooks.c (default_cxx_atexit_name): Remove.
 * targhooks.h (default_cxx_atexit_name): Remove prototype.
 * config/arm/arm.c (arm_cxx_atexit_name): Remove.
 (arm_cxx_use_aeabi_atexit): New function.
 (TARGET_CXX_ATEXIT_NAME): Remove.
 (TARGET_CXX_USE_AEABI_ATEXIT): New function.
 * doc/tm.texi: Document TARGET_CXX_USE_AEABI_ATEXIT.
 * cp/decl.c (get_atexit_node): Reorder arguments for __aeabi_atexit.
 (register_dtor_fn): Ditto.
Index: gcc/target-def.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/target-def.h,v
retrieving revision 1.59.2.14
diff -u -p -r1.59.2.14 target-def.h
--- gcc/target-def.h	5 Nov 2004 16:54:13 -0000	1.59.2.14
+++ gcc/target-def.h	8 Nov 2004 19:25:49 -0000
@@ -402,8 +402,8 @@ 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
+#ifndef TARGET_CXX_USE_AEABI_ATEXIT
+#define TARGET_CXX_USE_AEABI_ATEXIT hook_bool_void_false
 #endif
 
 #define TARGET_CXX				\
@@ -416,7 +416,7 @@ Foundation, 59 Temple Place - Suite 330,
     TARGET_CXX_KEY_METHOD_MAY_BE_INLINE,	\
     TARGET_CXX_EXPORT_CLASS_DATA, 		\
     TARGET_CXX_UNWIND_RESUME_NAME,		\
-    TARGET_CXX_ATEXIT_NAME			\
+    TARGET_CXX_USE_AEABI_ATEXIT			\
   }
 
 /* The whole shebang.  */
Index: gcc/target.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/target.h,v
retrieving revision 1.67.2.16
diff -u -p -r1.67.2.16 target.h
--- gcc/target.h	5 Nov 2004 16:54:13 -0000	1.67.2.16
+++ gcc/target.h	8 Nov 2004 19:44:36 -0000
@@ -479,7 +479,9 @@ struct gcc_target
     const char * (*unwind_resume_name) (void);
     /* Returns the name of the function used to register static object
        destructors.  */
-    const char * (*atexit_name) (void);
+    /* Returns true if __aeabi_atexit should be used to register static
+       destructors.  */
+    bool (*use_aeabi_atexit) (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.7
diff -u -p -r2.8.6.7 targhooks.c
--- gcc/targhooks.c	5 Nov 2004 16:54:13 -0000	2.8.6.7
+++ gcc/targhooks.c	8 Nov 2004 19:24:03 -0000
@@ -257,15 +257,6 @@ 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.7
diff -u -p -r2.3.6.7 targhooks.h
--- gcc/targhooks.h	5 Nov 2004 16:54:13 -0000	2.3.6.7
+++ gcc/targhooks.h	8 Nov 2004 19:25:02 -0000
@@ -40,6 +40,5 @@ 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.63
diff -u -p -r1.303.2.63 arm.c
--- gcc/config/arm/arm.c	5 Nov 2004 16:54:14 -0000	1.303.2.63
+++ gcc/config/arm/arm.c	8 Nov 2004 19:48:34 -0000
@@ -173,7 +173,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 bool arm_cxx_use_aeabi_atexit (void);
 static void arm_init_libfuncs (void);
 
 
@@ -290,8 +290,8 @@ 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_USE_AEABI_ATEXIT
+#define TARGET_CXX_USE_AEABI_ATEXIT arm_cxx_use_aeabi_atexit
 
 #undef TARGET_CXX_EXPORT_CLASS_DATA
 #define TARGET_CXX_EXPORT_CLASS_DATA arm_cxx_export_class_data
@@ -14680,16 +14680,13 @@ arm_cxx_export_class_data (void)
 }
 
 
-/* The EABI wants us to use __aeabi_atexit for registering static object
+/* The EABI says __aeabi_atexit should be used to register static
    destructors.  */
 
-static const char *
-arm_cxx_atexit_name (void)
+static bool
+arm_cxx_use_aeabi_atexit (void)
 {
-  if (TARGET_AAPCS_BASED)
-    return "__aeabi_atexit";
-  else
-    return default_cxx_atexit_name ();
+  return TARGET_AAPCS_BASED;
 }
 
 
Index: gcc/cp/decl.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/cp/decl.c,v
retrieving revision 1.1150.2.15
diff -u -p -r1.1150.2.15 decl.c
--- gcc/cp/decl.c	5 Nov 2004 16:54:15 -0000	1.1150.2.15
+++ gcc/cp/decl.c	8 Nov 2004 19:46:42 -0000
@@ -5021,6 +5021,7 @@ get_atexit_node (void)
   tree fn_type;
   tree fn_ptr_type;
   const char *name;
+  bool use_aeabi_atexit;
 
   if (atexit_node)
     return atexit_node;
@@ -5034,6 +5035,7 @@ get_atexit_node (void)
 	 We build up the argument types and then then function type
 	 itself.  */
 
+      use_aeabi_atexit = targetm.cxx.use_aeabi_atexit ();
       /* First, build the pointer-to-function type for the first
 	 argument.  */
       arg_types = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
@@ -5041,12 +5043,23 @@ get_atexit_node (void)
       fn_ptr_type = build_pointer_type (fn_type);
       /* Then, build the rest of the argument types.  */
       arg_types = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
-      arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types);
-      arg_types = tree_cons (NULL_TREE, fn_ptr_type, arg_types);
+      if (use_aeabi_atexit)
+	{
+	  arg_types = tree_cons (NULL_TREE, fn_ptr_type, arg_types);
+	  arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types);
+	}
+      else
+	{
+	  arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types);
+	  arg_types = tree_cons (NULL_TREE, fn_ptr_type, arg_types);
+	}
       /* 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 = targetm.cxx.atexit_name ();
+      if (use_aeabi_atexit)
+	name = "__aeabi_atexit";
+      else
+	name = "__cxa_atexit";
     }
   else
     {
@@ -5215,8 +5228,16 @@ register_dtor_fn (tree decl)
       args = tree_cons (NULL_TREE, 
 			build_unary_op (ADDR_EXPR, get_dso_handle_node (), 0),
 			NULL_TREE);
-      args = tree_cons (NULL_TREE, null_pointer_node, args);
-      args = tree_cons (NULL_TREE, cleanup, args);
+      if (targetm.cxx.use_aeabi_atexit ())
+	{
+	  args = tree_cons (NULL_TREE, cleanup, args);
+	  args = tree_cons (NULL_TREE, null_pointer_node, args);
+	}
+      else
+	{
+	  args = tree_cons (NULL_TREE, null_pointer_node, args);
+	  args = tree_cons (NULL_TREE, cleanup, args);
+	}
     }
   else
     args = tree_cons (NULL_TREE, cleanup, NULL_TREE);
Index: gcc/doc/tm.texi
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/doc/tm.texi,v
retrieving revision 1.264.2.23
diff -u -p -r1.264.2.23 tm.texi
--- gcc/doc/tm.texi	5 Nov 2004 17:25:20 -0000	1.264.2.23
+++ gcc/doc/tm.texi	8 Nov 2004 19:30:26 -0000
@@ -8616,10 +8616,10 @@ 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 the name of the function to use for registering
-static destructors when @option{-fuse-cxa-atexit} is in effect.
-The default is @code{"__cxa_atexit"}.
+@deftypefn {Target Hook} bool TARGET_CXX_USE_AEABI_ATEXIT (void)
+This hook returns true if @code{__aeabi_atexit} (as defined by the ARM EABI)
+should be used to register static destructors when @option{-fuse-cxa-atexit}
+is in effect.  The default is to return false to use @code{__cxa_atexit}.
 @end deftypefn
 
 @node Misc

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