summaryrefslogtreecommitdiff
path: root/tools/objtool
diff options
context:
space:
mode:
authorKristen Carlson Accardi <kristen@linux.intel.com>2020-04-16 00:04:43 +0300
committerJosh Poimboeuf <jpoimboe@redhat.com>2020-05-28 19:06:05 +0300
commite000acc145928693833f09152244242a678d3cd5 (patch)
treee643da8804969e058f6f68216ef2471de72f44a9 /tools/objtool
parent0decf1f8de919782b152daf9c991967a2bac54f0 (diff)
downloadlinux-e000acc145928693833f09152244242a678d3cd5.tar.xz
objtool: Do not assume order of parent/child functions
If a .cold function is examined prior to it's parent, the link to the parent/child function can be overwritten when the parent is examined. Only update pfunc and cfunc if they were previously nil to prevent this from happening. This fixes an issue seen when compiling with -ffunction-sections. Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Diffstat (limited to 'tools/objtool')
-rw-r--r--tools/objtool/elf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 84225679f96d..f953d3a15612 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -434,7 +434,13 @@ static int read_symbols(struct elf *elf)
size_t pnamelen;
if (sym->type != STT_FUNC)
continue;
- sym->pfunc = sym->cfunc = sym;
+
+ if (sym->pfunc == NULL)
+ sym->pfunc = sym;
+
+ if (sym->cfunc == NULL)
+ sym->cfunc = sym;
+
coldstr = strstr(sym->name, ".cold");
if (!coldstr)
continue;