From: Kristen Carlson Accardi Date: Wed, 15 Apr 2020 21:04:43 +0000 (-0700) Subject: objtool: Do not assume order of parent/child functions X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=e000acc145928693833f09152244242a678d3cd5;p=linux.git 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 Signed-off-by: Josh Poimboeuf --- diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 84225679f96da..f953d3a15612a 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;