diff options
author | mdodd <mdodd@FreeBSD.org> | 2003-04-07 16:21:26 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 2003-04-07 16:21:26 +0000 |
commit | 5ce5797f854a3c9afeef6e3aa4c3c251b63c3d24 (patch) | |
tree | 36bdb2349a03bc43a769c15fd3ddd1063c1bf86b /libexec/rtld-elf/rtld.c | |
parent | eff9d3d98df90c348751cebe8fd1aeaa8714e244 (diff) | |
download | FreeBSD-src-5ce5797f854a3c9afeef6e3aa4c3c251b63c3d24.zip FreeBSD-src-5ce5797f854a3c9afeef6e3aa4c3c251b63c3d24.tar.gz |
Dynamic object dependency mapping: libmap.
This is an optional feature, disabled by default.
This will be useful to people testing the various POSIX threading
libraries under -CURRENT but can easily serve other needs.
Diffstat (limited to 'libexec/rtld-elf/rtld.c')
-rw-r--r-- | libexec/rtld-elf/rtld.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 2016ce0..2bd6584 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -52,6 +52,9 @@ #include "debug.h" #include "rtld.h" +#ifdef WITH_LIBMAP +#include "libmap.h" +#endif #define END_SYM "_end" #define PATH_RTLD "/usr/libexec/ld-elf.so.1" @@ -366,6 +369,10 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) sym_zero.st_info = ELF_ST_INFO(STB_GLOBAL, STT_NOTYPE); sym_zero.st_shndx = SHN_UNDEF; +#ifdef WITH_LIBMAP + lm_init(); +#endif + dbg("loading LD_PRELOAD libraries"); if (load_preload_objects() == -1) die(); @@ -802,19 +809,25 @@ elf_hash(const char *name) * /usr/lib */ static char * -find_library(const char *name, const Obj_Entry *refobj) +find_library(const char *xname, const Obj_Entry *refobj) { char *pathname; + char *name; - if (strchr(name, '/') != NULL) { /* Hard coded pathname */ - if (name[0] != '/' && !trust) { + if (strchr(xname, '/') != NULL) { /* Hard coded pathname */ + if (xname[0] != '/' && !trust) { _rtld_error("Absolute pathname required for shared object \"%s\"", - name); + xname); return NULL; } - return xstrdup(name); + return xstrdup(xname); } +#ifdef WITH_LIBMAP + if ((name = lm_find(refobj->path, xname)) == NULL) +#endif + name = (char *)xname; + dbg(" Searching for \"%s\"", name); if ((pathname = search_library_path(name, ld_library_path)) != NULL || @@ -1468,6 +1481,9 @@ rtld_exit(void) obj->refcount = 0; objlist_call_fini(&list_fini); /* No need to remove the items from the list, since we are exiting. */ +#ifdef WITH_LIBMAP + lm_fini(); +#endif } static void * |