From f91f1c0fb89056995f1c9c6a06c361efdf5139e7 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Fri, 28 Jun 2013 16:20:26 +0100 Subject: [BZ #15022] Correct global-scope dlopen issues in static executables. This change creates a link map in static executables to serve as the global search list for dlopen. It fixes a problem with the inability to access the global symbol object and a crash on an attempt to map a DSO into the global scope. Some code that has become dead after the addition of this link map is removed too and test cases are provided. --- elf/dl-open.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'elf/dl-open.c') diff --git a/elf/dl-open.c b/elf/dl-open.c index 15221c8..7adf66b 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -204,11 +204,9 @@ dl_open_worker (void *a) { const void *caller_dlopen = args->caller_dlopen; -#ifdef SHARED /* We have to find out from which object the caller is calling. By default we assume this is the main application. */ call_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; -#endif struct link_map *l = _dl_find_dso_for_object ((ElfW(Addr)) caller_dlopen); @@ -216,15 +214,7 @@ dl_open_worker (void *a) call_map = l; if (args->nsid == __LM_ID_CALLER) - { -#ifndef SHARED - /* In statically linked apps there might be no loaded object. */ - if (call_map == NULL) - args->nsid = LM_ID_BASE; - else -#endif - args->nsid = call_map->l_ns; - } + args->nsid = call_map->l_ns; } assert (_dl_debug_initialize (0, args->nsid)->r_state == RT_CONSISTENT); @@ -642,12 +632,6 @@ no more namespaces available for dlmopen()")); || GL(dl_ns)[nsid]._ns_loaded->l_auditing)) _dl_signal_error (EINVAL, file, NULL, N_("invalid target namespace in dlmopen()")); -#ifndef SHARED - else if ((nsid == LM_ID_BASE || nsid == __LM_ID_CALLER) - && GL(dl_ns)[LM_ID_BASE]._ns_loaded == NULL - && GL(dl_nns) == 0) - GL(dl_nns) = 1; -#endif struct dl_open_args args; args.file = file; -- cgit v1.1