diff options
| author | Mark Johnston <markj@FreeBSD.org> | 2013-12-27 22:54:38 +0000 |
|---|---|---|
| committer | Mark Johnston <markj@FreeBSD.org> | 2013-12-27 22:54:38 +0000 |
| commit | 24aadf3ce06e025a223915331096ca69c64463e2 (patch) | |
| tree | c473f08c836241b49efdfb165588492ffcd9aa1e /lib/libproc/proc_sym.c | |
| parent | 4060bb2cab2b0b06f6b1ea1a7e2bf26031f278e5 (diff) | |
Notes
Diffstat (limited to 'lib/libproc/proc_sym.c')
| -rw-r--r-- | lib/libproc/proc_sym.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c index 8582bf325722..cd7bc77434a2 100644 --- a/lib/libproc/proc_sym.c +++ b/lib/libproc/proc_sym.c @@ -254,7 +254,7 @@ proc_addr2sym(struct proc_handle *p, uintptr_t addr, char *name, */ 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, uintptr_t addr, char *name, } } } +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, const char *object, const char *symbol, * 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, const char *object, const char *symbol, */ 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: |
