Author: andrew Date: Tue Nov 13 15:28:27 2018 New Revision: 340395 URL: https://svnweb.freebsd.org/changeset/base/340395
Log: Run __cxa_finalize in shared objects in the destructor path. When we have .dtors call them before .dtor handling, otherwise call from a destructor. PR: 233056 MFC with: r339738 Sponsored by: DARPA, AFRL Modified: head/lib/csu/common/crtbegin.c Modified: head/lib/csu/common/crtbegin.c ============================================================================== --- head/lib/csu/common/crtbegin.c Tue Nov 13 13:57:15 2018 (r340394) +++ head/lib/csu/common/crtbegin.c Tue Nov 13 15:28:27 2018 (r340395) @@ -32,12 +32,29 @@ typedef void (*crt_func)(void); extern void *__dso_handle __hidden; -#ifdef SHARED -void *__dso_handle = &__dso_handle; -#else +#ifndef SHARED void *__dso_handle = 0; +#else +void *__dso_handle = &__dso_handle; +void __cxa_finalize(void *) __weak_symbol; + +/* + * Call __cxa_finalize with the dso handle in shared objects. + * When we have ctors/dtors call from the dtor handler before calling + * any dtors, otherwise use a destructor. + */ +#ifndef HAVE_CTORS +__attribute__((destructor)) #endif +static void +run_cxa_finalize(void) +{ + if (__cxa_finalize != NULL) + __cxa_finalize(__dso_handle); +} +#endif + /* * On some architectures and toolchains we may need to call the .dtors. * These are called in the order they are in the ELF file. @@ -57,6 +74,10 @@ __do_global_dtors_aux(void) { crt_func fn; int n; + +#ifdef SHARED + run_cxa_finalize(); +#endif for (n = 1;; n++) { fn = __DTOR_LIST__[n]; _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"