diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-06-27 11:45:12 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-06-27 11:45:12 +0000 |
commit | 51fecd257a3a6aade53e635fe9d174478255f3d9 (patch) | |
tree | 8adbb904f4792932432753f427ea841da2672146 /ldso/libdl | |
parent | 980f13fc4095e11aa0a0b5914d4008f0ed1ae0d0 (diff) | |
download | uClibc-alpine-51fecd257a3a6aade53e635fe9d174478255f3d9.tar.bz2 uClibc-alpine-51fecd257a3a6aade53e635fe9d174478255f3d9.tar.xz |
Run dlopened ctors and dtors in the correct order
Diffstat (limited to 'ldso/libdl')
-rw-r--r-- | ldso/libdl/dlib.c | 12 | ||||
-rw-r--r-- | ldso/libdl/libdl.c | 12 |
2 files changed, 16 insertions, 8 deletions
diff --git a/ldso/libdl/dlib.c b/ldso/libdl/dlib.c index 999139538..c2949c981 100644 --- a/ldso/libdl/dlib.c +++ b/ldso/libdl/dlib.c @@ -181,7 +181,7 @@ void *_dlopen(const char *libname, int flag) //tpnt->libtype = loaded_file; dyn_chain = rpnt = (struct dyn_elf *) malloc(sizeof(struct dyn_elf)); - _dl_memset(rpnt, 0, sizeof(*rpnt)); + _dl_memset(rpnt, 0, sizeof(struct dyn_elf)); rpnt->dyn = tpnt; rpnt->flags = flag; if (!tpnt->symbol_scope) @@ -213,7 +213,7 @@ void *_dlopen(const char *libname, int flag) goto oops; rpnt->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf)); - _dl_memset (rpnt->next, 0, sizeof (*(rpnt->next))); + _dl_memset (rpnt->next, 0, sizeof (struct dyn_elf)); rpnt = rpnt->next; if (!tpnt1->symbol_scope) tpnt1->symbol_scope = dyn_chain; rpnt->dyn = tpnt1; @@ -254,8 +254,12 @@ void *_dlopen(const char *libname, int flag) } #ifdef __PIC__ - for (rpnt = dyn_chain; rpnt; rpnt = rpnt->next) { - tpnt = rpnt->dyn; + /* Find the last library */ + for (tpnt = dyn_chain->dyn; tpnt->next!=NULL; tpnt = tpnt->next) + ; + /* Run the ctors and set up the dtors */ + for (; tpnt != dyn_chain->dyn->prev; tpnt=tpnt->prev) + { /* Apparently crt1 for the application is responsible for handling this. * We only need to run the init/fini for shared libraries */ diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index 999139538..c2949c981 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -181,7 +181,7 @@ void *_dlopen(const char *libname, int flag) //tpnt->libtype = loaded_file; dyn_chain = rpnt = (struct dyn_elf *) malloc(sizeof(struct dyn_elf)); - _dl_memset(rpnt, 0, sizeof(*rpnt)); + _dl_memset(rpnt, 0, sizeof(struct dyn_elf)); rpnt->dyn = tpnt; rpnt->flags = flag; if (!tpnt->symbol_scope) @@ -213,7 +213,7 @@ void *_dlopen(const char *libname, int flag) goto oops; rpnt->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf)); - _dl_memset (rpnt->next, 0, sizeof (*(rpnt->next))); + _dl_memset (rpnt->next, 0, sizeof (struct dyn_elf)); rpnt = rpnt->next; if (!tpnt1->symbol_scope) tpnt1->symbol_scope = dyn_chain; rpnt->dyn = tpnt1; @@ -254,8 +254,12 @@ void *_dlopen(const char *libname, int flag) } #ifdef __PIC__ - for (rpnt = dyn_chain; rpnt; rpnt = rpnt->next) { - tpnt = rpnt->dyn; + /* Find the last library */ + for (tpnt = dyn_chain->dyn; tpnt->next!=NULL; tpnt = tpnt->next) + ; + /* Run the ctors and set up the dtors */ + for (; tpnt != dyn_chain->dyn->prev; tpnt=tpnt->prev) + { /* Apparently crt1 for the application is responsible for handling this. * We only need to run the init/fini for shared libraries */ |