Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Dec 2013 22:54:38 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
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
Message-ID:  <201312272254.rBRMscDw062929@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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:



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