/* Specialized bits of code needed to support construction and
destruction of file-scope objects in C++ code.
- Copyright (C) 1991-2019 Free Software Foundation, Inc.
+ Copyright (C) 1991-2021 Free Software Foundation, Inc.
Contributed by Ron Guilmette (rfg@monkeys.com).
This file is part of GCC.
#ifdef OBJECT_FORMAT_ELF
+#if DEFAULT_USE_CXA_ATEXIT
/* Declare the __dso_handle variable. It should have a unique value
in every shared-object; in a main program its value is zero. The
object should in any case be protected. This means the instance
in one DSO or the main program is not used in another object. The
- dynamic linker takes care of this. */
+ dynamic linker takes care of this.
+ If __cxa_atexit is not being used, __dso_handle will not be used and
+ doesn't need to be defined. */
#ifdef TARGET_LIBGCC_SDATA_SECTION
extern void *__dso_handle __attribute__ ((__section__ (TARGET_LIBGCC_SDATA_SECTION)));
#else
void *__dso_handle = 0;
#endif
+#endif /* DEFAULT_USE_CXA_ATEXIT */
/* The __cxa_finalize function may not be available so we use only a
weak declaration. */
On some systems, this routine is run more than once from the .fini,
when exit is called recursively, so we arrange to remember where in
the list we left off processing, and we resume at that point,
- should we be re-invoked. */
+ should we be re-invoked.
+ This routine does not need to be run if none of the following clauses are
+ true, as it will not do anything, so can be removed. */
+#if defined(CRTSTUFFS_O) || !defined(FINI_ARRAY_SECTION_ASM_OP) \
+ || USE_TM_CLONE_REGISTRY || defined(USE_EH_FRAME_REGISTRY)
static void __attribute__((used))
__do_global_dtors_aux (void)
{
if (__builtin_expect (completed, 0))
return;
+#if DEFAULT_USE_CXA_ATEXIT
#ifdef CRTSTUFFS_O
if (__cxa_finalize)
__cxa_finalize (__dso_handle);
#endif
+#endif
#ifdef FINI_ARRAY_SECTION_ASM_OP
/* If we are using .fini_array then destructors will be run via that
CRT_CALL_STATIC_FUNCTION (__LIBGCC_INIT_SECTION_ASM_OP__,
__do_global_dtors_aux_1)
#endif
+#endif /* defined(CRTSTUFFS_O) || !defined(FINI_ARRAY_SECTION_ASM_OP)
+ || USE_TM_CLONE_REGISTRY || defined(USE_EH_FRAME_REGISTRY) */
#if defined(USE_EH_FRAME_REGISTRY) || USE_TM_CLONE_REGISTRY
/* Stick a call to __register_frame_info into the .init section. For some