+2005-04-05 Paul Brook <julian@codesourcery.com>
+
+ * 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.
+
2005-04-25 Ian Lance Taylor <ian@airs.com>
* c-common.def (EXPR_STMT): Remove, moved to C++ frontend.
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);
\f
#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
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)
{
tree fn_type;
tree fn_ptr_type;
const char *name;
+ bool use_aeabi_atexit;
if (atexit_node)
return atexit_node;
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);
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 = "__cxa_atexit";
+ if (use_aeabi_atexit)
+ name = "__aeabi_atexit";
+ else
+ name = "__cxa_atexit";
}
else
{
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);
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
#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, \
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. */
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. */