summaryrefslogtreecommitdiff
path: root/elf/dl-open.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@codesourcery.com>2013-06-28 16:20:26 +0100
committerMaciej W. Rozycki <macro@codesourcery.com>2013-06-28 16:22:20 +0100
commitf91f1c0fb89056995f1c9c6a06c361efdf5139e7 (patch)
tree67db98c499e8dbd72bc5b49e654706d375384c0f /elf/dl-open.c
parented0257f7d3378ec4a72e297f0dcba5159f2dd138 (diff)
[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.
Diffstat (limited to 'elf/dl-open.c')
-rw-r--r--elf/dl-open.c18
1 files changed, 1 insertions, 17 deletions
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 15221c8d57..7adf66b221 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;