Index: include/dlfcn.h =================================================================== RCS file: /cvs/src/include/dlfcn.h,v retrieving revision 1.9 diff -u -r1.9 dlfcn.h --- include/dlfcn.h 11 Aug 2004 19:14:56 -0000 1.9 +++ include/dlfcn.h 24 Aug 2006 22:56:47 -0000 @@ -64,6 +64,7 @@ #define RTLD_GLOBAL 0x100 #define RTLD_LOCAL 0x000 #define DL_LAZY RTLD_LAZY /* Compat */ +#define RTLD_TRACE 0x200 /* * Special handle arguments for dlsym(). Index: libexec/ld.so/dlfcn.c =================================================================== RCS file: /cvs/src/libexec/ld.so/dlfcn.c,v retrieving revision 1.73 diff -u -r1.73 dlfcn.c --- libexec/ld.so/dlfcn.c 8 May 2006 20:34:36 -0000 1.73 +++ libexec/ld.so/dlfcn.c 24 Aug 2006 22:56:59 -0000 @@ -53,6 +53,9 @@ if (libname == NULL) return RTLD_DEFAULT; + if ((flags & RTLD_TRACE) == RTLD_TRACE) + _dl_traceld = "true"; + DL_DEB(("dlopen: loading: %s\n", libname)); _dl_thread_kern_stop(); @@ -95,6 +98,11 @@ } else { int err; DL_DEB(("tail %s\n", object->load_name )); + if (_dl_traceld) { + _dl_show_objects(); + _dl_unload_shlib(object); + _dl_exit(0); + } err = _dl_rtld(object); if (err != 0) { _dl_real_close(object); @@ -365,13 +373,23 @@ objtypename = "rtld"; break; case OBJTYPE_EXE: - objtypename = "exe "; + if (_dl_debug) + objtypename = "exe "; + else { + object = object->next; + continue; + } break; case OBJTYPE_LIB: objtypename = "rlib"; break; case OBJTYPE_DLO: - objtypename = "dlib"; + if (_dl_debug) + objtypename = "dlib"; + else { + object = object->next; + continue; + } break; default: objtypename = "????"; Index: libexec/ld.so/ldd/ldd.c =================================================================== RCS file: /cvs/src/libexec/ld.so/ldd/ldd.c,v retrieving revision 1.11 diff -u -r1.11 ldd.c --- libexec/ld.so/ldd/ldd.c 10 Jul 2003 00:04:28 -0000 1.11 +++ libexec/ld.so/ldd/ldd.c 24 Aug 2006 22:56:59 -0000 @@ -31,10 +31,12 @@ #include #include #include +#include #include #include #include +#include int usage(void); int doit(char *); @@ -93,8 +95,9 @@ Elf_Ehdr ehdr; Elf_Phdr *phdr; int fd, i, size, status; + char buf[MAXPATHLEN]; + void * dlhandle; - printf("%s:\n", name); if ((fd = open(name, O_RDONLY)) < 0) { warn("%s", name); @@ -114,6 +117,21 @@ return 1; } + if (ehdr.e_type == ET_DYN) { + printf("%s:\n", name); + if (realpath(name, buf) == NULL) { + warn("realpath(%s)", name); + return 1; + } + dlhandle = dlopen(buf, RTLD_TRACE); + if (dlhandle == NULL) { + printf("%s\n", dlerror()); + return 1; + } + close(fd); + return 0; + } + size = ehdr.e_phnum * sizeof(Elf_Phdr); if ((phdr = malloc(size)) == NULL) err(1, "malloc"); @@ -135,6 +153,7 @@ return 1; } + printf("%s:\n", name); fflush(stdout); switch (fork()) { case -1: