summaryrefslogtreecommitdiff
path: root/tools/objtool/elf.c
diff options
context:
space:
mode:
authorLuka Pivk <luka.pivk@toradex.com>2019-01-08 13:52:27 +0100
committerLuka Pivk <luka.pivk@toradex.com>2019-01-08 13:52:27 +0100
commite9dcc568b2e968af848bbdb4267ba6cde5457b9e (patch)
tree4cc0a7e7220770f30d0c7c6989feaa8e73c9f1c1 /tools/objtool/elf.c
parent6a082d8b56f739188cdcbac7cf412775a20447df (diff)
parent457e6884cb33a86aef7e86119955ee3d87da6815 (diff)
Merge remote-tracking branch 'remotes/origin/linux-4.19.y-rt'
Signed-off-by: Luka Pivk <luka.pivk@toradex.com>
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 7ec85d567598..b75d004f6482 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;