diff options
author | kib <kib@FreeBSD.org> | 2011-01-30 16:14:09 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2011-01-30 16:14:09 +0000 |
commit | eb600b11804e80fee6e15936da93f554b907ea76 (patch) | |
tree | fa2813f83ff852b97d0e491520a066af64090adc /libexec | |
parent | 71ec4b8793a3cb5044e713945787b810d02f235e (diff) | |
download | FreeBSD-src-eb600b11804e80fee6e15936da93f554b907ea76.zip FreeBSD-src-eb600b11804e80fee6e15936da93f554b907ea76.tar.gz |
Make ldd(1) work when versioned dependency file is cannot be loaded.
Instead of aborting in locate_dependency(), propagate the error to
caller. The rtld startup function does the right thing with an error
from rtld_verify_versions(), depending on the mode of operation.
Reported by: maho
In collaboration with: kan
MFC after: 1 week
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/rtld-elf/rtld.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 11ef847..ee97708 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3704,10 +3704,17 @@ locate_dependency(const Obj_Entry *obj, const char *name) } for (needed = obj->needed; needed != NULL; needed = needed->next) { - if (needed->obj == NULL) - continue; - if (object_match_name(needed->obj, name)) - return needed->obj; + if (strcmp(obj->strtab + needed->name, name) == 0 || + (needed->obj != NULL && object_match_name(needed->obj, name))) { + /* + * If there is DT_NEEDED for the name we are looking for, + * we are all set. Note that object might not be found if + * dependency was not loaded yet, so the function can + * return NULL here. This is expected and handled + * properly in caller. + */ + return (needed->obj); + } } _rtld_error("%s: Unexpected inconsistency: dependency %s not found", obj->path, name); @@ -3833,6 +3840,8 @@ rtld_verify_object_versions(Obj_Entry *obj) vn = obj->verneed; while (vn != NULL) { depobj = locate_dependency(obj, obj->strtab + vn->vn_file); + if (depobj == NULL) + return (-1); vna = (const Elf_Vernaux *) ((char *)vn + vn->vn_aux); for (;;) { if (check_object_provided_version(obj, depobj, vna)) |