From owner-svn-src-stable@FreeBSD.ORG Fri Dec 27 22:54:39 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 38AEB892; Fri, 27 Dec 2013 22:54:39 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0AAF617A9; Fri, 27 Dec 2013 22:54:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBRMscPf062930; Fri, 27 Dec 2013 22:54:38 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBRMscDw062929; Fri, 27 Dec 2013 22:54:38 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201312272254.rBRMscDw062929@svn.freebsd.org> From: Mark Johnston Date: Fri, 27 Dec 2013 22:54:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r259970 - stable/9/lib/libproc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2013 22:54:39 -0000 Author: markj Date: Fri Dec 27 22:54:38 2013 New Revision: 259970 URL: http://svnweb.freebsd.org/changeset/base/259970 Log: MFC r240040 (rpaulo): Make sure we visit both symbol sections even if one of them doesn't exist. This makes it possible to dtrace some C++ programs like devd. MFC r254177 (rpaulo): Fix the return value when we found a symbol in .dynstr. This nasty bug was preventing a lot of symbol lookups in dtruss -s, for example. Modified: stable/9/lib/libproc/proc_sym.c Directory Properties: stable/9/lib/libproc/ (props changed) Modified: stable/9/lib/libproc/proc_sym.c ============================================================================== --- stable/9/lib/libproc/proc_sym.c Fri Dec 27 22:30:36 2013 (r259969) +++ stable/9/lib/libproc/proc_sym.c Fri Dec 27 22:54:38 2013 (r259970) @@ -254,7 +254,7 @@ proc_addr2sym(struct proc_handle *p, uin */ if ((data = elf_getdata(dynsymscn, NULL)) == NULL) { DPRINTFX("ERROR: elf_getdata() failed: %s", elf_errmsg(-1)); - goto err2; + goto symtab; } i = 0; while (gelf_getsym(data, i++, &sym) != NULL) { @@ -279,6 +279,7 @@ proc_addr2sym(struct proc_handle *p, uin } } } +symtab: /* * Iterate over the Symbols Table to find the symbol. * Then look up the string name in STRTAB (.dynstr) @@ -430,17 +431,16 @@ proc_name2sym(struct proc_handle *p, con * Iterate over the Dynamic Symbols table to find the symbol. * Then look up the string name in STRTAB (.dynstr) */ - if ((data = elf_getdata(dynsymscn, NULL)) == NULL) { - goto err2; - } - i = 0; - while (gelf_getsym(data, i++, &sym) != NULL) { - s = elf_strptr(e, dynsymstridx, sym.st_name); - if (s && strcmp(s, symbol) == 0) { - memcpy(symcopy, &sym, sizeof(sym)); - symcopy->st_value = map->pr_vaddr + sym.st_value; - error = 0; - goto out; + if ((data = elf_getdata(dynsymscn, NULL))) { + i = 0; + while (gelf_getsym(data, i++, &sym) != NULL) { + s = elf_strptr(e, dynsymstridx, sym.st_name); + if (s && strcmp(s, symbol) == 0) { + memcpy(symcopy, &sym, sizeof(sym)); + symcopy->st_value = map->pr_vaddr + sym.st_value; + error = 0; + goto out; + } } } /* @@ -449,17 +449,15 @@ proc_name2sym(struct proc_handle *p, con */ if (symtabscn == NULL) goto err2; - if ((data = elf_getdata(symtabscn, NULL)) == NULL) { - DPRINTF("ERROR: elf_getdata() failed"); - goto err2; - } - i = 0; - while (gelf_getsym(data, i++, &sym) != NULL) { - s = elf_strptr(e, symtabstridx, sym.st_name); - if (s && strcmp(s, symbol) == 0) { - memcpy(symcopy, &sym, sizeof(sym)); - error = 0; - goto out; + if ((data = elf_getdata(symtabscn, NULL))) { + i = 0; + while (gelf_getsym(data, i++, &sym) != NULL) { + s = elf_strptr(e, symtabstridx, sym.st_name); + if (s && strcmp(s, symbol) == 0) { + memcpy(symcopy, &sym, sizeof(sym)); + error = 0; + goto out; + } } } out: