aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-error.c11
-rw-r--r--elf/dl-sym.c38
2 files changed, 30 insertions, 19 deletions
diff --git a/elf/dl-error.c b/elf/dl-error.c
index e802c27763..eda2725c5f 100644
--- a/elf/dl-error.c
+++ b/elf/dl-error.c
@@ -1,5 +1,5 @@
/* Error handling for runtime dynamic linker.
- Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -75,12 +75,13 @@ _dl_signal_error (int errcode,
lcatch->errstring = malloc (objname_len + errstring_len);
if (lcatch->errstring != NULL)
{
+ char *cp = lcatch->errstring;
if (objname_len > 0)
{
- memcpy (lcatch->errstring, objname, objname_len - 2);
- memcpy (lcatch->errstring + objname_len - 2, ": ", 2);
+ cp = __mempcpy (cp, objname, objname_len - 2);
+ cp = __mempcpy (cp, ": ", 2);
}
- memcpy (lcatch->errstring + objname_len, errstring, errstring_len);
+ memcpy (cp, errstring, errstring_len);
}
longjmp (lcatch->env, errcode ?: -1);
}
@@ -89,7 +90,7 @@ _dl_signal_error (int errcode,
/* Lossage while resolving the program's own symbols is always fatal. */
char buffer[1024];
_dl_sysdep_fatal (_dl_argv[0] ?: "<program name unknown>",
- ": error in loading shared libraries: ",
+ ": error while loading shared libraries: ",
objname ?: "", objname && *objname ? ": " : "",
errstring, errcode ? ": " : "",
(errcode
diff --git a/elf/dl-sym.c b/elf/dl-sym.c
index 91ca1277df..80be9544cb 100644
--- a/elf/dl-sym.c
+++ b/elf/dl-sym.c
@@ -35,7 +35,7 @@ _dl_sym (void *handle, const char *name, void *who)
if (handle == RTLD_DEFAULT)
/* Search the global scope. */
loadbase = _dl_lookup_symbol (name, NULL, &ref, _dl_global_scope, 0);
- else if (handle == RTLD_NEXT)
+ else
{
struct link_map *l, *match;
ElfW(Addr) caller = (ElfW(Addr)) who;
@@ -46,22 +46,32 @@ _dl_sym (void *handle, const char *name, void *who)
if (caller >= l->l_addr && (!match || match->l_addr < l->l_addr))
match = l;
- if (! match)
- _dl_signal_error (0, NULL, _("\
+ if (handle != RTLD_NEXT)
+ {
+ /* Search the scope of the given object. */
+ struct link_map *map = handle;
+
+ if (match == NULL)
+ /* If the address is not recognized the call comes from the
+ main program (we hope). */
+ match = _dl_loaded;
+
+ loadbase = _dl_lookup_symbol (name, match, &ref, map->l_local_scope,
+ 0);
+ }
+ else
+ {
+ if (! match)
+ _dl_signal_error (0, NULL, _("\
RTLD_NEXT used in code not dynamically loaded"));
- l = match;
- while (l->l_loader)
- l = l->l_loader;
+ l = match;
+ while (l->l_loader)
+ l = l->l_loader;
- loadbase = _dl_lookup_symbol_skip (name, l, &ref, l->l_local_scope,
- match);
- }
- else
- {
- /* Search the scope of the given object. */
- struct link_map *map = handle;
- loadbase = _dl_lookup_symbol (name, map, &ref, map->l_local_scope, 0);
+ loadbase = _dl_lookup_symbol_skip (name, l, &ref, l->l_local_scope,
+ match);
+ }
}
if (loadbase)