Skip to content

Commit e000acc

Browse files
kaccardijpoimboe
authored andcommitted
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 <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]>
1 parent 0decf1f commit e000acc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/objtool/elf.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,13 @@ static int read_symbols(struct elf *elf)
434434
size_t pnamelen;
435435
if (sym->type != STT_FUNC)
436436
continue;
437-
sym->pfunc = sym->cfunc = sym;
437+
438+
if (sym->pfunc == NULL)
439+
sym->pfunc = sym;
440+
441+
if (sym->cfunc == NULL)
442+
sym->cfunc = sym;
443+
438444
coldstr = strstr(sym->name, ".cold");
439445
if (!coldstr)
440446
continue;

0 commit comments

Comments
 (0)