summaryrefslogtreecommitdiff
path: root/ldso/ldso/ldso.c
diff options
context:
space:
mode:
authorJoakim Tjernlund <joakim.tjernlund@transmode.se>2007-03-31 13:42:48 +0000
committerJoakim Tjernlund <joakim.tjernlund@transmode.se>2007-03-31 13:42:48 +0000
commitdae8a4ede6fec3e6f87f101c2708c2669c4075fa (patch)
tree4cbe358ff1e21a00108eb01520b252395e90b663 /ldso/ldso/ldso.c
parent39d1a8c871a46e603a60f210b6aa19bf7d1eedc4 (diff)
Bernd Schmidt writes:
Currently a static libdl.a doesn't run all the constructors or destructors of the libraries it loads. I can't see a good reason for that, and it does cause aborts in the destructors it does run for things like libgcc.so on the Blackfin. Fixed with the patch below - untested in mainline, but the equivalent has been in our Blackfin tree for a while now.
Diffstat (limited to 'ldso/ldso/ldso.c')
-rw-r--r--ldso/ldso/ldso.c52
1 files changed, 1 insertions, 51 deletions
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index e2a10737c..e1101bd57 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -66,6 +66,7 @@ int _dl_debug_file = 2;
unsigned long attribute_hidden _dl_skip_args = 0;
const char *_dl_progname = UCLIBC_LDSO; /* The name of the executable being run */
#include "dl-startup.c"
+#include "dl-array.c"
/* Forward function declarations */
static int _dl_suid_ok(void);
@@ -107,57 +108,6 @@ uintptr_t __guard attribute_relro;
# endif
#endif
-static void _dl_run_array_forward(unsigned long array, unsigned long size,
- DL_LOADADDR_TYPE loadaddr)
-{
- if (array != 0) {
- unsigned int j;
- unsigned int jm;
- ElfW(Addr) *addrs;
- jm = size / sizeof (ElfW(Addr));
- addrs = (ElfW(Addr) *) DL_RELOC_ADDR(loadaddr, array);
- for (j = 0; j < jm; ++j) {
- void (*dl_elf_func) (void);
- dl_elf_func = (void (*)(void)) (intptr_t) addrs[j];
- DL_CALL_FUNC_AT_ADDR (dl_elf_func, loadaddr, (void (*)(void)));
- }
- }
-}
-
-void _dl_run_init_array(struct elf_resolve *tpnt);
-void _dl_run_init_array(struct elf_resolve *tpnt)
-{
- _dl_run_array_forward(tpnt->dynamic_info[DT_INIT_ARRAY],
- tpnt->dynamic_info[DT_INIT_ARRAYSZ],
- tpnt->loadaddr);
-}
-
-void _dl_app_init_array(void);
-void _dl_app_init_array(void)
-{
- _dl_run_init_array(_dl_loaded_modules);
-}
-
-void _dl_run_fini_array(struct elf_resolve *tpnt);
-void _dl_run_fini_array(struct elf_resolve *tpnt)
-{
- if (tpnt->dynamic_info[DT_FINI_ARRAY]) {
- ElfW(Addr) *array = (ElfW(Addr) *) DL_RELOC_ADDR(tpnt->loadaddr, tpnt->dynamic_info[DT_FINI_ARRAY]);
- unsigned int i = (tpnt->dynamic_info[DT_FINI_ARRAYSZ] / sizeof(ElfW(Addr)));
- while (i-- > 0) {
- void (*dl_elf_func) (void);
- dl_elf_func = (void (*)(void)) (intptr_t) array[i];
- DL_CALL_FUNC_AT_ADDR (dl_elf_func, tpnt->loadaddr, (void (*)(void)));
- }
- }
-}
-
-void _dl_app_fini_array(void);
-void _dl_app_fini_array(void)
-{
- _dl_run_fini_array(_dl_loaded_modules);
-}
-
static void __attribute__ ((destructor)) __attribute_used__ _dl_fini(void)
{
int i;