summaryrefslogtreecommitdiffstats
path: root/contrib/elftoolchain/nm
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2015-02-25 21:43:09 +0000
committeremaste <emaste@FreeBSD.org>2015-02-25 21:43:09 +0000
commitfc3e39a724ec345b7d21e4174c71d5fb1b89c7dd (patch)
tree7f1d5edd08f1828202b454de8ae6a3849009365f /contrib/elftoolchain/nm
parentc36da9e30f4010c1cf2c06d56a7b4449ed67ccab (diff)
downloadFreeBSD-src-fc3e39a724ec345b7d21e4174c71d5fb1b89c7dd.zip
FreeBSD-src-fc3e39a724ec345b7d21e4174c71d5fb1b89c7dd.tar.gz
nm: avoid crash in print_lineno if func->name is NULL
This can occur when DW_AT_specification is used to refer to another DIE that provides the actual DW_AT_name string. For example: < 3><0x00000086> DW_TAG_subprogram DW_AT_name PrettyStackTraceEntry ... < 1><0x00002cf4> DW_TAG_subprogram DW_AT_specification <0x00000086> We will need to add support for DW_AT_specification, but in the interim we should not segfault. Obtained from: Elftoolchain (r3170) Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'contrib/elftoolchain/nm')
-rw-r--r--contrib/elftoolchain/nm/nm.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/elftoolchain/nm/nm.c b/contrib/elftoolchain/nm/nm.c
index f984966..637cdd9 100644
--- a/contrib/elftoolchain/nm/nm.c
+++ b/contrib/elftoolchain/nm/nm.c
@@ -1525,7 +1525,8 @@ print_lineno(struct sym_entry *ep, struct func_info_head *func_info,
/* For function symbol, search the function line information list. */
if ((ep->sym->st_info & 0xf) == STT_FUNC && func_info != NULL) {
SLIST_FOREACH(func, func_info, entries) {
- if (!strcmp(ep->name, func->name) &&
+ if (func->name != NULL &&
+ !strcmp(ep->name, func->name) &&
ep->sym->st_value >= func->lowpc &&
ep->sym->st_value < func->highpc) {
printf("\t%s:%" PRIu64, func->file, func->line);
OpenPOWER on IntegriCloud