Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Jan 2011 16:14:10 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r218098 - head/libexec/rtld-elf
Message-ID:  <201101301614.p0UGEAjx077282@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Jan 30 16:14:09 2011
New Revision: 218098
URL: http://svn.freebsd.org/changeset/base/218098

Log:
  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

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Sun Jan 30 15:36:59 2011	(r218097)
+++ head/libexec/rtld-elf/rtld.c	Sun Jan 30 16:14:09 2011	(r218098)
@@ -3704,10 +3704,17 @@ locate_dependency(const Obj_Entry *obj, 
     }
 
     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 *o
     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))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101301614.p0UGEAjx077282>