From 2244c71124b3a33cbb065e524dbdc0662099d7c2 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Fri, 16 Feb 2007 18:02:50 +0000 Subject: Fix dlopen for static apps. From Carmelo Amoroso. --- ldso/ldso/dl-elf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 31dd75729..e67257e18 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -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; -- cgit v1.2.3