Don't register the destructors if the list is empty
authorChris Lattner <sabre@nondot.org>
Thu, 26 Jun 2003 04:20:38 +0000 (04:20 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 26 Jun 2003 04:20:38 +0000 (04:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6909 91177308-0d34-0410-b5e6-96231b3b80d8

runtime/GCCLibraries/crtend/crtend.c

index 69eac4ff9887f55f9c78df9f0a5f14e61004ced1..50bbdb708141c913e2eabafed844582afe43ce15 100644 (file)
@@ -34,8 +34,12 @@ void __main(void) {
   /* Loop over all of the constructor records, calling each function pointer. */
   TorRec *R = __llvm_getGlobalCtors();
 
-  if (atexit(run_destructors))
-    abort();  /* Should be able to install ONE atexit handler! */
+  /* Only register the global dtor handler if there is at least one global
+   * dtor!
+   */
+  if (__llvm_getGlobalDtors()[0].FP)
+    if (atexit(run_destructors))
+      abort();  /* Should be able to install ONE atexit handler! */
 
   /* FIXME: This should sort the list by priority! */
   for (; R->FP; ++R)