aboutsummaryrefslogtreecommitdiff
path: root/tools/objtool/elf.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2018-12-21 09:57:42 +0000
committerMark Brown <broonie@kernel.org>2018-12-21 09:57:42 +0000
commit4ab452c56f5c65636fbf1cf0a7b43cd5c05889b6 (patch)
tree24cb63796feaf1fe4d2bd8a6c2298c5974fdde62 /tools/objtool/elf.c
parent43603a35574c2e594f9e10a97a40874d1282dd7e (diff)
parente95d10da90f48177a1ffd3fef90c9997977cfc24 (diff)
downloadlinux-linaro-stable-4ab452c56f5c65636fbf1cf0a7b43cd5c05889b6.tar.gz
Merge branch 'linux-linaro-lsk-v4.9' into linux-linaro-lsk-v4.9-rtlinux-linaro-lsk-v4.9-rt
Diffstat (limited to 'tools/objtool/elf.c')
-rw-r--r--tools/objtool/elf.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 0d1acb704f64..dd4ed7c3c062 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -31,6 +31,8 @@
#include "elf.h"
#include "warn.h"
+#define MAX_NAME_LEN 128
+
struct section *find_section_by_name(struct elf *elf, const char *name)
{
struct section *sec;
@@ -298,6 +300,8 @@ static int read_symbols(struct elf *elf)
/* Create parent/child links for any cold subfunctions */
list_for_each_entry(sec, &elf->sections, list) {
list_for_each_entry(sym, &sec->symbol_list, list) {
+ char pname[MAX_NAME_LEN + 1];
+ size_t pnamelen;
if (sym->type != STT_FUNC)
continue;
sym->pfunc = sym->cfunc = sym;
@@ -305,14 +309,21 @@ static int read_symbols(struct elf *elf)
if (!coldstr)
continue;
- coldstr[0] = '\0';
- pfunc = find_symbol_by_name(elf, sym->name);
- coldstr[0] = '.';
+ pnamelen = coldstr - sym->name;
+ if (pnamelen > MAX_NAME_LEN) {
+ WARN("%s(): parent function name exceeds maximum length of %d characters",
+ sym->name, MAX_NAME_LEN);
+ return -1;
+ }
+
+ strncpy(pname, sym->name, pnamelen);
+ pname[pnamelen] = '\0';
+ pfunc = find_symbol_by_name(elf, pname);
if (!pfunc) {
WARN("%s(): can't find parent function",
sym->name);
- goto err;
+ return -1;
}
sym->pfunc = pfunc;