OSDN Git Service

Fix dlopen for static apps.
authorJoakim Tjernlund <joakim.tjernlund@transmode.se>
Fri, 16 Feb 2007 18:02:50 +0000 (18:02 -0000)
committerJoakim Tjernlund <joakim.tjernlund@transmode.se>
Fri, 16 Feb 2007 18:02:50 +0000 (18:02 -0000)
From Carmelo Amoroso.

ldso/ldso/dl-elf.c

index 31dd757..e67257e 100644 (file)
@@ -607,9 +607,19 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                _dl_memset((*rpnt)->next, 0, sizeof(struct dyn_elf));
                (*rpnt)->next->prev = (*rpnt);
                *rpnt = (*rpnt)->next;
-               (*rpnt)->dyn = tpnt;
-               tpnt->symbol_scope = _dl_symbol_tables;
        }
+#ifndef SHARED
+       /* When statically linked, the first time we dlopen a DSO
+        * the *rpnt is NULL, so we need to allocate memory for it,
+        * and initialize the _dl_symbol_table.
+        */ 
+       else {
+               *rpnt = _dl_symbol_tables = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
+               _dl_memset(*rpnt, 0, sizeof(struct dyn_elf));
+       }
+#endif
+       (*rpnt)->dyn = tpnt;
+       tpnt->symbol_scope = _dl_symbol_tables;
        tpnt->usage_count++;
        tpnt->libtype = elf_lib;