From fd8767bb695bfa9a537ad36df46aa972ba48bd99 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Fri, 26 Oct 2018 11:53:20 +0000 Subject: [PATCH] Add __dso_handle to the BSD crtbegin. This is used to identify shared objects. MFC with: r339738 Sponsored by: DARPA, AFRL --- lib/csu/common/crtbegin.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/csu/common/crtbegin.c b/lib/csu/common/crtbegin.c index 46e604927ac0..c5fd6fe57d34 100644 --- a/lib/csu/common/crtbegin.c +++ b/lib/csu/common/crtbegin.c @@ -30,6 +30,14 @@ __FBSDID("$FreeBSD$"); typedef void (*crt_func)(void); +extern void *__dso_handle __hidden; + +#ifdef SHARED +void *__dso_handle = &__dso_handle; +#else +void *__dso_handle = 0; +#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.