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:
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to