diff options
Diffstat (limited to 'lib/csu/common/crtend.c')
-rw-r--r-- | lib/csu/common/crtend.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/csu/common/crtend.c b/lib/csu/common/crtend.c index d9259729bb0e..9eb75de2ef60 100644 --- a/lib/csu/common/crtend.c +++ b/lib/csu/common/crtend.c @@ -21,15 +21,11 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/cdefs.h> +#include <sys/types.h> #include "crt.h" typedef void (*crt_func)(void); -static crt_func __JCR_END__[] __section(".jcr") __used = { - (crt_func)0 -}; - #ifdef HAVE_CTORS /* @@ -45,15 +41,22 @@ static crt_func __DTOR_END__[] __section(".dtors") __used = { (crt_func)0 }; +extern const char startof_ctors[] __asm(".startof..ctors") + __weak_symbol __hidden; + static void __do_global_ctors_aux(void) { crt_func fn; + uintptr_t ctors_start; int n; + ctors_start = (uintptr_t)&startof_ctors; for (n = 1;; n++) { fn = __CTOR_END__[-n]; - if (fn == (crt_func)0 || fn == (crt_func)-1) + if (fn == (crt_func)0 || fn == (crt_func)-1 || + (ctors_start > 0 && + (uintptr_t)&__CTOR_END__[-n] < ctors_start)) break; fn(); } |