From 0fe5e45ee9dcad107bf7078642b40bcd2145e112 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 26 Jun 2003 04:20:38 +0000 Subject: [PATCH] Don't register the destructors if the list is empty llvm-svn: 6909 --- llvm/runtime/GCCLibraries/crtend/crtend.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/llvm/runtime/GCCLibraries/crtend/crtend.c b/llvm/runtime/GCCLibraries/crtend/crtend.c index 69eac4ff9887..50bbdb708141 100644 --- a/llvm/runtime/GCCLibraries/crtend/crtend.c +++ b/llvm/runtime/GCCLibraries/crtend/crtend.c @@ -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)