]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgcc/crtstuff.c
Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856).
[thirdparty/gcc.git] / libgcc / crtstuff.c
index 4bea6b9f8ccc5759852d3bf722b6020744cdcb76..d81c527a4550af0e11a69220036d1320040c73c6 100644 (file)
@@ -1,6 +1,6 @@
 /* Specialized bits of code needed to support construction and
    destruction of file-scope objects in C++ code.
-   Copyright (C) 1991-2014 Free Software Foundation, Inc.
+   Copyright (C) 1991-2018 Free Software Foundation, Inc.
    Contributed by Ron Guilmette (rfg@monkeys.com).
 
 This file is part of GCC.
@@ -81,7 +81,7 @@ call_ ## FUNC (void)                                  \
 #endif
 
 #if defined(TARGET_DL_ITERATE_PHDR) && \
-   (defined(__DragonFly__) || defined(__FreeBSD__))
+   (defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__))
 #define BSD_DL_ITERATE_PHDR_AVAILABLE
 #endif
  
@@ -131,7 +131,12 @@ call_ ## FUNC (void)                                       \
 # define USE_PT_GNU_EH_FRAME
 #endif
 
-#if defined(__LIBGCC_EH_FRAME_SECTION_NAME__) && !defined(USE_PT_GNU_EH_FRAME)
+#ifdef USE_EH_FRAME_REGISTRY_ALWAYS
+# ifndef __LIBGCC_EH_FRAME_SECTION_NAME__
+#  error "Can't use explicit exception-frame-registration without __LIBGCC_EH_FRAME_SECTION_NAME__"
+# endif
+#endif
+#if defined(__LIBGCC_EH_FRAME_SECTION_NAME__) && (!defined(USE_PT_GNU_EH_FRAME) || defined(USE_EH_FRAME_REGISTRY_ALWAYS))
 # define USE_EH_FRAME_REGISTRY
 #endif
 #if defined(__LIBGCC_EH_FRAME_SECTION_NAME__) \
@@ -183,9 +188,6 @@ extern void *__deregister_frame_info_bases (const void *)
                                     TARGET_ATTRIBUTE_WEAK;
 extern void __do_global_ctors_1 (void);
 
-/* Likewise for _Jv_RegisterClasses.  */
-extern void _Jv_RegisterClasses (void *) TARGET_ATTRIBUTE_WEAK;
-
 /* Likewise for transactional memory clone tables.  */
 extern void _ITM_registerTMCloneTable (void *, size_t) TARGET_ATTRIBUTE_WEAK;
 extern void _ITM_deregisterTMCloneTable (void *) TARGET_ATTRIBUTE_WEAK;
@@ -261,15 +263,6 @@ STATIC EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[]
      = { };
 #endif /* USE_EH_FRAME_REGISTRY */
 
-#ifdef __LIBGCC_JCR_SECTION_NAME__
-/* Stick a label at the beginning of the java class registration info
-   so we can register them properly.  */
-STATIC void *__JCR_LIST__[]
-  __attribute__ ((used, section(__LIBGCC_JCR_SECTION_NAME__),
-                 aligned(sizeof(void*))))
-  = { };
-#endif /* __LIBGCC_JCR_SECTION_NAME__ */
-
 #if USE_TM_CLONE_REGISTRY
 STATIC func_ptr __TMC_LIST__[]
   __attribute__((used, section(".tm_clone_table"), aligned(sizeof(void*))))
@@ -284,7 +277,10 @@ deregister_tm_clones (void)
   void (*fn) (void *);
 
 #ifdef HAVE_GAS_HIDDEN
-  if (__TMC_END__ - __TMC_LIST__ == 0)
+  func_ptr *end = __TMC_END__;
+  // Do not optimize the comparison to false.
+  __asm ("" : "+g" (end));
+  if (__TMC_LIST__ == end)
     return;
 #else
   if (__TMC_LIST__[0] == NULL)
@@ -304,7 +300,10 @@ register_tm_clones (void)
   size_t size;
 
 #ifdef HAVE_GAS_HIDDEN
-  size = (__TMC_END__ - __TMC_LIST__) / 2;
+  func_ptr *end = __TMC_END__;
+  // Do not optimize the comparison to false.
+  __asm ("" : "+g" (end));
+  size = (end - __TMC_LIST__) / 2;
 #else
   for (size = 0; __TMC_LIST__[size * 2] != NULL; size++)
     continue;
@@ -388,13 +387,11 @@ __do_global_dtors_aux (void)
     extern func_ptr __DTOR_END__[] __attribute__((visibility ("hidden")));
     static size_t dtor_idx;
     const size_t max_idx = __DTOR_END__ - __DTOR_LIST__ - 1;
-    func_ptr f;
+    func_ptr *dtor_list;
 
+    __asm ("" : "=g" (dtor_list) : "0" (__DTOR_LIST__));
     while (dtor_idx < max_idx)
-      {
-       f = __DTOR_LIST__[++dtor_idx];
-       f ();
-      }
+      dtor_list[++dtor_idx] ();
   }
 #else /* !defined (FINI_ARRAY_SECTION_ASM_OP) */
   {
@@ -446,7 +443,6 @@ CRT_CALL_STATIC_FUNCTION (__LIBGCC_INIT_SECTION_ASM_OP__,
 #endif
 
 #if defined(USE_EH_FRAME_REGISTRY) \
-    || defined(__LIBGCC_JCR_SECTION_NAME__) \
     || defined(USE_TM_CLONE_REGISTRY)
 /* Stick a call to __register_frame_info into the .init section.  For some
    reason calls with no arguments work more reliably in .init, so stick the
@@ -469,18 +465,6 @@ frame_dummy (void)
 #endif /* CRT_GET_RFIB_DATA */
 #endif /* USE_EH_FRAME_REGISTRY */
 
-#ifdef __LIBGCC_JCR_SECTION_NAME__
-  void **jcr_list;
-  __asm ("" : "=g" (jcr_list) : "0" (__JCR_LIST__));
-  if (__builtin_expect (*jcr_list != NULL, 0))
-    {
-      void (*register_classes) (void *) = _Jv_RegisterClasses;
-      __asm ("" : "+r" (register_classes));
-      if (register_classes)
-       register_classes (jcr_list);
-    }
-#endif /* __LIBGCC_JCR_SECTION_NAME__ */
-
 #if USE_TM_CLONE_REGISTRY
   register_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
@@ -493,7 +477,7 @@ static func_ptr __frame_dummy_init_array_entry[]
   __attribute__ ((__used__, section(".init_array"), aligned(sizeof(func_ptr))))
   = { frame_dummy };
 #endif /* !defined(__LIBGCC_INIT_SECTION_ASM_OP__) */
-#endif /* USE_EH_FRAME_REGISTRY || __LIBGCC_JCR_SECTION_NAME__ || USE_TM_CLONE_REGISTRY */
+#endif /* USE_EH_FRAME_REGISTRY || USE_TM_CLONE_REGISTRY */
 
 #else  /* OBJECT_FORMAT_ELF */
 
@@ -561,7 +545,6 @@ __do_global_dtors (void)
 }
 
 #if defined(USE_EH_FRAME_REGISTRY) \
-    || defined(__LIBGCC_JCR_SECTION_NAME__) \
     || defined(USE_TM_CLONE_REGISTRY)
 /* A helper function for __do_global_ctors, which is in crtend.o.  Here
    in crtbegin.o, we can reference a couple of symbols not visible there.
@@ -576,23 +559,11 @@ __do_global_ctors_1(void)
     __register_frame_info (__EH_FRAME_BEGIN__, &object);
 #endif
 
-#ifdef __LIBGCC_JCR_SECTION_NAME__
-  void **jcr_list
-  __asm ("" : "=g" (jcr_list) : "0" (__JCR_LIST__));
-  if (__builtin_expect (*jcr_list != NULL, 0))
-    {
-      void (*register_classes) (void *) = _Jv_RegisterClasses;
-      __asm ("" : "+r" (register_classes));
-      if (register_classes)
-       register_classes (jcr_list);
-    }
-#endif
-
 #if USE_TM_CLONE_REGISTRY
   register_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
 }
-#endif /* USE_EH_FRAME_REGISTRY || __LIBGCC_JCR_SECTION_NAME__ || USE_TM_CLONE_REGISTRY */
+#endif /* USE_EH_FRAME_REGISTRY || USE_TM_CLONE_REGISTRY */
 
 #else /* ! __LIBGCC_INIT_SECTION_ASM_OP__ && ! HAS_INIT_SECTION */
 #error "What are you doing with crtstuff.c, then?"
@@ -668,14 +639,6 @@ STATIC EH_FRAME_SECTION_CONST int32 __FRAME_END__[]
      = { 0 };
 #endif /* __LIBGCC_EH_FRAME_SECTION_NAME__ */
 
-#ifdef __LIBGCC_JCR_SECTION_NAME__
-/* Null terminate the .jcr section array.  */
-STATIC void *__JCR_END__[1]
-   __attribute__ ((used, section(__LIBGCC_JCR_SECTION_NAME__),
-                  aligned(sizeof(void *))))
-   = { 0 };
-#endif /* __LIBGCC_JCR_SECTION_NAME__ */
-
 #if USE_TM_CLONE_REGISTRY
 # ifndef HAVE_GAS_HIDDEN
 static
@@ -754,7 +717,6 @@ __do_global_ctors (void)
 {
   func_ptr *p;
 #if defined(USE_EH_FRAME_REGISTRY) \
-    || defined(__LIBGCC_JCR_SECTION_NAME__) \
     || defined(USE_TM_CLONE_REGISTRY)
   __do_global_ctors_1();
 #endif