From: Rich Felker Date: Wed, 31 Jul 2013 04:04:10 +0000 (-0400) Subject: don't call null pointer if DT_INIT/DT_FINI are null X-Git-Tag: v0.9.13~115 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d0c6cb05e71e624338571cda28f5c17d3ab0004c;p=oweals%2Fmusl.git don't call null pointer if DT_INIT/DT_FINI are null it's not clear to me why the linker even outputs these headers if they are null, but apparently it does so. with the default startfiles, they will never be null anyway, but this patch allows eliminating crti, crtn, crtbegin, and crtend (leaving only crt1) if the toolchain is using init_array/fini_array (or for a C-only, no-ctor environment). --- diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index 8d857d72..3c963e22 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -715,7 +715,7 @@ static void do_fini() while (n--) ((void (*)(void))*--fn)(); } #ifndef NO_LEGACY_INITFINI - if (dyn[0] & (1<base + dyn[DT_FINI]))(); #endif } @@ -738,7 +738,7 @@ static void do_init_fini(struct dso *p) fini_head = p; } #ifndef NO_LEGACY_INITFINI - if (dyn[0] & (1<base + dyn[DT_INIT]))(); #endif if (dyn[0] & (1<