summaryrefslogtreecommitdiff
path: root/src/ldso
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-11-30 17:56:23 -0500
committerRich Felker <dalias@aerifal.cx>2012-11-30 17:56:23 -0500
commita7936f61b23100ac32f51776c5b3e52452c7598c (patch)
treef389101a0cd75932cf5b027d99d49e38233eabe7 /src/ldso
parent1c322f2f0a9173a3ae8c8bfa12d5d8e92fb5d0ab (diff)
downloadmusl-a7936f61b23100ac32f51776c5b3e52452c7598c.tar.gz
musl-a7936f61b23100ac32f51776c5b3e52452c7598c.tar.bz2
musl-a7936f61b23100ac32f51776c5b3e52452c7598c.tar.xz
musl-a7936f61b23100ac32f51776c5b3e52452c7598c.zip
fix ordering of shared library ctors with respect to libc init
previously, shared library constructors were being called before important internal things like the environment (extern char **environ) and hwcap flags (needed for sjlj to work right with float on arm) were initialized in __libc_start_main. rather than trying to have to dynamic linker make sure this stuff all gets initialized right, I've opted to just defer calling shared library constructors until after the main program's entry point is reached. this also fixes the order of ctors to be the exact reverse of dtors, which is a desirable property and possibly even mandated by some languages. the main practical effect of this change is that shared libraries calling getenv from ctors will no longer fail.
Diffstat (limited to 'src/ldso')
-rw-r--r--src/ldso/dynlink.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index c436b88f..d564b8f2 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -999,13 +999,16 @@ void *__dynlink(int argc, char **argv)
if (ssp_used) __init_ssp((void *)aux[AT_RANDOM]);
- atexit(do_fini);
- do_init_fini(tail);
-
errno = 0;
return (void *)aux[AT_ENTRY];
}
+void __init_ldso_ctors(void)
+{
+ atexit(do_fini);
+ do_init_fini(tail);
+}
+
void *dlopen(const char *file, int mode)
{
struct dso *volatile p, *orig_tail, *next;