From 84de44d3f213d2c600b05bfe010d2f6fc84c5cfc Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 4 Jul 2017 20:19:36 +0000 Subject: [PATCH] When reporting undefined symbol, note the version, if specified. Use the standard syntax of name@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 --- libexec/rtld-elf/rtld.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 61beae035fb5..5d77b9cc0f7d 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -1659,6 +1659,7 @@ find_symdef(unsigned long symnum, const Obj_Entry *refobj, 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 *refobj, 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 *refobj, } 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 *refobj, } } 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, const Ver_Entry *ve, 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;