Skip to content

Commit

Permalink
objtool: Allow STT_NOTYPE -> STT_FUNC+0 tail-calls
Browse files Browse the repository at this point in the history
Allow STT_NOTYPE to tail-call into STT_FUNC, per definition STT_NOTYPE
is not a sub-function of the STT_FUNC.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Peter Zijlstra authored and KAGA-KOKO committed Aug 1, 2022
1 parent 1f2a15c commit 1da8c35
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions tools/objtool/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,16 @@ static void add_return_call(struct objtool_file *file, struct instruction *insn,

static bool same_function(struct instruction *insn1, struct instruction *insn2)
{
if (!insn1->func && !insn2->func)
return true;

/* Allow STT_NOTYPE -> STT_FUNC+0 tail-calls */
if (!insn1->func && insn1->func != insn2->func)
return false;

if (!insn2->func)
return true;

return insn1->func->pfunc == insn2->func->pfunc;
}

Expand Down Expand Up @@ -1487,18 +1497,19 @@ static int add_jump_destinations(struct objtool_file *file)
strstr(jump_dest->func->name, ".cold")) {
insn->func->cfunc = jump_dest->func;
jump_dest->func->pfunc = insn->func;

} else if (!same_function(insn, jump_dest) &&
is_first_func_insn(file, jump_dest)) {
/*
* Internal sibling call without reloc or with
* STT_SECTION reloc.
*/
add_call_dest(file, insn, jump_dest->func, true);
continue;
}
}

if (!same_function(insn, jump_dest) &&
is_first_func_insn(file, jump_dest)) {
/*
* Internal sibling call without reloc or with
* STT_SECTION reloc.
*/
add_call_dest(file, insn, jump_dest->func, true);
continue;
}

insn->jump_dest = jump_dest;
}

Expand Down

0 comments on commit 1da8c35

Please sign in to comment.