svn commit: r320658 - head/libexec/rtld-elf

Konstantin Belousov kib at FreeBSD.org
Tue Jul 4 20:19:37 UTC 2017


Author: kib
Date: Tue Jul  4 20:19:36 2017
New Revision: 320658
URL: https://svnweb.freebsd.org/changeset/base/320658

Log:
  When reporting undefined symbol, note the version, if specified.
  
  Use the standard syntax of name at version, I do not expect a confusion
  due to unlikely possibility of the name containing the '@' character.
  
  Requested by:	emaste
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

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

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Tue Jul  4 18:48:08 2017	(r320657)
+++ head/libexec/rtld-elf/rtld.c	Tue Jul  4 20:19:36 2017	(r320658)
@@ -1659,6 +1659,7 @@ find_symdef(unsigned long symnum, const Obj_Entry *ref
     const Elf_Sym *ref;
     const Elf_Sym *def;
     const Obj_Entry *defobj;
+    const Ver_Entry *ve;
     SymLook req;
     const char *name;
     int res;
@@ -1678,6 +1679,7 @@ find_symdef(unsigned long symnum, const Obj_Entry *ref
     name = refobj->strtab + ref->st_name;
     def = NULL;
     defobj = NULL;
+    ve = NULL;
 
     /*
      * We don't have to do a full scale lookup if the symbol is local.
@@ -1694,7 +1696,7 @@ find_symdef(unsigned long symnum, const Obj_Entry *ref
 	}
 	symlook_init(&req, name);
 	req.flags = flags;
-	req.ventry = fetch_ventry(refobj, symnum);
+	ve = req.ventry = fetch_ventry(refobj, symnum);
 	req.lockstate = lockstate;
 	res = symlook_default(&req, refobj);
 	if (res == 0) {
@@ -1724,7 +1726,8 @@ find_symdef(unsigned long symnum, const Obj_Entry *ref
 	}
     } else {
 	if (refobj != &obj_rtld)
-	    _rtld_error("%s: Undefined symbol \"%s\"", refobj->path, name);
+	    _rtld_error("%s: Undefined symbol \"%s%s%s\"", refobj->path, name,
+	      ve != NULL ? "@" : "", ve != NULL ? ve->name : "");
     }
     return def;
 }
@@ -3489,7 +3492,8 @@ do_dlsym(void *handle, const char *name, void *retaddr
 	return (sym);
     }
 
-    _rtld_error("Undefined symbol \"%s\"", name);
+    _rtld_error("Undefined symbol \"%s%s%s\"", name, ve != NULL ? "@" : "",
+      ve != NULL ? ve->name : "");
     lock_release(rtld_bind_lock, &lockstate);
     LD_UTRACE(UTRACE_DLSYM_STOP, handle, NULL, 0, 0, name);
     return NULL;


More information about the svn-src-head mailing list