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]

Re: [PATCH] Use __aeabi_atexit for ARM EABI


Paul Brook wrote:
On Tuesday 19 April 2005 21:06, Julian Brown wrote:

ChangeLog (Paul Brook):

 * 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.


Not ok. This was superceded by this patch:

http://gcc.gnu.org/ml/gcc-patches/2004-11/msg01323.html

Here's a version based on the superceding patch, re-tested on arm-none-eabi with cross and native on x86_64-linux.


OK to apply?

Julian

ChangeLog (Paul Brook, edited):

    * target-def.h (TARGET_CXX_USE_AEABI_ATEXIT): Define.
    * target.h (struct gcc_target): Add cxx.use_aeabi_atexit.
    * config/arm/arm.c (arm_cxx_atexit_name): New function.
    (TARGET_CXX_USE_AEABI_ATEXIT): New macro.
    * cp/decl.c (get_atexit_node): Reorder arguments for __aeabi_atexit.
    (register_dtor_fn): Likewise.
    * doc/tm.texi: Document TARGET_CXX_USE_AEABI_ATEXIT.
Index: gcc/target-def.h
===================================================================
RCS file: /home/gcc/repos/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.119
diff -c -p -r1.119 target-def.h
*** gcc/target-def.h	12 Apr 2005 06:33:23 -0000	1.119
--- gcc/target-def.h	20 Apr 2005 16:51:15 -0000
*************** Foundation, 59 Temple Place - Suite 330,
*** 477,482 ****
--- 477,486 ----
  #define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_true
  #endif
  
+ #ifndef TARGET_CXX_USE_AEABI_ATEXIT
+ #define TARGET_CXX_USE_AEABI_ATEXIT hook_bool_void_false
+ #endif
+ 
  #define TARGET_CXX				\
    {						\
      TARGET_CXX_GUARD_TYPE,			\
*************** Foundation, 59 Temple Place - Suite 330,
*** 488,493 ****
--- 492,498 ----
      TARGET_CXX_KEY_METHOD_MAY_BE_INLINE,	\
      TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY,	\
      TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT,        \
+     TARGET_CXX_USE_AEABI_ATEXIT			\
    }
  
  /* The whole shebang.  */
Index: gcc/target.h
===================================================================
RCS file: /home/gcc/repos/gcc/gcc/gcc/target.h,v
retrieving revision 1.131
diff -c -p -r1.131 target.h
*** gcc/target.h	12 Apr 2005 06:33:23 -0000	1.131
--- gcc/target.h	21 Apr 2005 00:04:49 -0000
*************** struct gcc_target
*** 603,608 ****
--- 603,611 ----
         class data for classes whose virtual table will be emitted in
         only one translation unit will not be COMDAT.  */
      bool (*class_data_always_comdat) (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/config/arm/arm.c
===================================================================
RCS file: /home/gcc/repos/gcc/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.442
diff -c -p -r1.442 arm.c
*** gcc/config/arm/arm.c	12 Apr 2005 06:33:25 -0000	1.442
--- gcc/config/arm/arm.c	20 Apr 2005 16:47:58 -0000
*************** static bool arm_cxx_cdtor_returns_this (
*** 174,179 ****
--- 174,180 ----
  static bool arm_cxx_key_method_may_be_inline (void);
  static void arm_cxx_determine_class_data_visibility (tree);
  static bool arm_cxx_class_data_always_comdat (void);
+ static bool arm_cxx_use_aeabi_atexit (void);
  static void arm_init_libfuncs (void);
  static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode);
  
*************** static unsigned HOST_WIDE_INT arm_shift_
*** 308,313 ****
--- 309,317 ----
  #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_USE_AEABI_ATEXIT
+ #define TARGET_CXX_USE_AEABI_ATEXIT arm_cxx_use_aeabi_atexit
+ 
  #undef TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY
  #define TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY \
    arm_cxx_determine_class_data_visibility
*************** arm_cxx_class_data_always_comdat (void)
*** 14346,14351 ****
--- 14350,14366 ----
       vague linkage if the class has no key function.  */
    return !TARGET_AAPCS_BASED;
  }
+ 
+ 
+ /* The EABI says __aeabi_atexit should be used to register static
+    destructors.  */
+ 
+ static bool
+ arm_cxx_use_aeabi_atexit (void)
+ {
+   return TARGET_AAPCS_BASED;
+ }
+ 
  
  void
  arm_set_return_address (rtx source, rtx scratch)
Index: gcc/cp/decl.c
===================================================================
RCS file: /home/gcc/repos/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1386
diff -c -p -r1.1386 decl.c
*** gcc/cp/decl.c	18 Apr 2005 13:39:38 -0000	1.1386
--- gcc/cp/decl.c	20 Apr 2005 16:46:12 -0000
*************** get_atexit_node (void)
*** 4995,5000 ****
--- 4995,5001 ----
    tree fn_type;
    tree fn_ptr_type;
    const char *name;
+   bool use_aeabi_atexit;
  
    if (atexit_node)
      return atexit_node;
*************** get_atexit_node (void)
*** 5008,5013 ****
--- 5009,5015 ----
  	 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);
*************** get_atexit_node (void)
*** 5015,5026 ****
        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);
        /* 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";
      }
    else
      {
--- 5017,5039 ----
        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);
!       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);
!       if (use_aeabi_atexit)
! 	name = "__aeabi_atexit";
!       else
! 	name = "__cxa_atexit";
      }
    else
      {
*************** register_dtor_fn (tree decl)
*** 5181,5188 ****
        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);
      }
    else
      args = tree_cons (NULL_TREE, cleanup, NULL_TREE);
--- 5194,5209 ----
        args = tree_cons (NULL_TREE,
  			build_unary_op (ADDR_EXPR, get_dso_handle_node (), 0),
  			NULL_TREE);
!       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: /home/gcc/repos/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.423
diff -c -p -r1.423 tm.texi
*** gcc/doc/tm.texi	15 Apr 2005 10:24:13 -0000	1.423
--- gcc/doc/tm.texi	20 Apr 2005 16:50:09 -0000
*************** classes whose virtual table will be emit
*** 8735,8740 ****
--- 8735,8746 ----
  unit will not be COMDAT.
  @end deftypefn
  
+ @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
  @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]