From d9873126f6ca1d91a7453a54be79b6408e5f4fd6 Mon Sep 17 00:00:00 2001 From: kib Date: Sat, 28 Nov 2009 14:29:32 +0000 Subject: [PATCH] Allow to load not-openable dso when tracing. This fixes ldd on such dso or dso linked to non-openable object. Remove '\n' at the end of error message. End comments with dot. MFC after: 3 weeks (together with r199829) --- libexec/rtld-elf/rtld.c | 7 +++++-- libexec/rtld-elf/rtld.h | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 320aa854c8b3..bffae60d573c 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -1571,9 +1571,10 @@ do_load_object(int fd, const char *name, char *path, struct stat *sbp, object_add_name(obj, name); obj->path = path; digest_dynamic(obj, 0); - if (obj->z_noopen && (flags & RTLD_LO_DLOPEN)) { + if (obj->z_noopen && (flags & (RTLD_LO_DLOPEN | RTLD_LO_TRACE)) == + RTLD_LO_DLOPEN) { dbg("refusing to load non-loadable \"%s\"", obj->path); - _rtld_error("Cannot dlopen non-loadable %s\n", obj->path); + _rtld_error("Cannot dlopen non-loadable %s", obj->path); munmap(obj->mapbase, obj->mapsize); obj_free(obj); return (NULL); @@ -2006,6 +2007,8 @@ dlopen(const char *name, int mode) lo_flags = RTLD_LO_DLOPEN; if (mode & RTLD_NOLOAD) lo_flags |= RTLD_LO_NOLOAD; + if (ld_tracing != NULL) + lo_flags |= RTLD_LO_TRACE; objlist_init(&initlist); diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index 6f51d7db7820..875e84bc7e63 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -242,8 +242,9 @@ typedef struct Struct_Obj_Entry { dlsym. */ /* Flags for load_object(). */ -#define RTLD_LO_NOLOAD 0x01 /* dlopen() specified RTLD_NOLOAD */ -#define RTLD_LO_DLOPEN 0x02 /* load_object() called from dlopen(). */ +#define RTLD_LO_NOLOAD 0x01 /* dlopen() specified RTLD_NOLOAD. */ +#define RTLD_LO_DLOPEN 0x02 /* Load_object() called from dlopen(). */ +#define RTLD_LO_TRACE 0x04 /* Only tracing. */ /* * Symbol cache entry used during relocation to avoid multiple lookups