aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-load.c13
-rw-r--r--elf/dl-open.c11
-rw-r--r--elf/dlopen.c2
-rw-r--r--elf/link.h8
4 files changed, 18 insertions, 16 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 4821073..f947bb8 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -469,13 +469,24 @@ _dl_map_object (struct link_map *loader, const char *name, int type)
}
fd = -1;
- for (l = loader; l; l = l->l_loader)
+
+ /* First try the DT_RPATH of the dependent object that caused NAME
+ to be loaded. Then that object's dependent, and on up. */
+ for (l = loader; fd == -1 && l; l = l->l_loader)
if (l && l->l_info[DT_RPATH])
trypath ((const char *) (l->l_addr +
l->l_info[DT_STRTAB]->d_un.d_ptr +
l->l_info[DT_RPATH]->d_un.d_val));
+ /* If dynamically linked, try the DT_RPATH of the executable itself. */
+ l = _dl_loaded;
+ if (fd == -1 && l && l->l_type != lt_loaded)
+ trypath ((const char *) (l->l_addr +
+ l->l_info[DT_STRTAB]->d_un.d_ptr +
+ l->l_info[DT_RPATH]->d_un.d_val));
+ /* Try an environment variable (unless setuid). */
if (fd == -1 && ! _dl_secure)
trypath (getenv ("LD_LIBRARY_PATH"));
+ /* Finally, try the default path. */
if (fd == -1)
{
extern const char *_dl_rpath; /* Set in rtld.c. */
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 8171837..c24920f 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -25,22 +25,15 @@ Cambridge, MA 02139, USA. */
size_t _dl_global_scope_alloc;
struct link_map *
-_dl_open (struct link_map *parent, const char *file, int mode)
+_dl_open (const char *file, int mode)
{
struct link_map *new, *l;
ElfW(Addr) init;
struct r_debug *r;
-#ifdef PIC
- if (! parent)
- /* If no particular dependent object caused this load,
- then use the DT_RPATH of the executable itself. */
- parent = _dl_loaded;
-#endif
-
/* Load the named object. */
- new = _dl_map_object (parent, file, lt_loaded);
+ new = _dl_map_object (NULL, file, lt_loaded);
if (new->l_searchlist)
/* It was already open. */
return new;
diff --git a/elf/dlopen.c b/elf/dlopen.c
index e261fca..9de787d 100644
--- a/elf/dlopen.c
+++ b/elf/dlopen.c
@@ -28,7 +28,7 @@ dlopen (const char *file, int mode)
void doit (void)
{
- new = _dl_open (_dl_loaded, file ?: "", mode);
+ new = _dl_open (file ?: "", mode);
}
return _dlerror_run (doit) ? NULL : new;
diff --git a/elf/link.h b/elf/link.h
index f43ec41..1e0104a 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -205,11 +205,9 @@ extern void _dl_setup_hash (struct link_map *map);
/* Open the shared object NAME, relocate it, and run its initializer if it
- hasn't already been run. LOADER's DT_RPATH is used in searching for
- NAME. MODE is as for `dlopen' (see <dlfcn.h>). If the object is
- already opened, returns its existing map. */
-extern struct link_map *_dl_open (struct link_map *loader,
- const char *name, int mode);
+ hasn't already been run. MODE is as for `dlopen' (see <dlfcn.h>). If
+ the object is already opened, returns its existing map. */
+extern struct link_map *_dl_open (const char *name, int mode);
/* Close an object previously opened by _dl_open. */
extern void _dl_close (struct link_map *map);