Skip to content

Commit

Permalink
objtool: Generate ORC data for __pfx code
Browse files Browse the repository at this point in the history
Allow unwinding from prefix code by copying the CFI from the starting
instruction of the corresponding function.  Even when the NOPs are
replaced, they're still stack-invariant instructions so the same ORC
entry can be reused everywhere.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/bc3344e51f3e87102f1301a0be0f72a7689ea4a4.1681331135.git.jpoimboe@kernel.org
  • Loading branch information
Josh Poimboeuf authored and Peter Zijlstra committed Apr 14, 2023
1 parent 4a2c344 commit 5743654
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tools/objtool/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -4117,6 +4117,7 @@ static bool ignore_unreachable_insn(struct objtool_file *file, struct instructio
static int add_prefix_symbol(struct objtool_file *file, struct symbol *func)
{
struct instruction *insn, *prev;
struct cfi_state *cfi;

insn = find_insn(file, func->sec, func->offset);
if (!insn)
Expand Down Expand Up @@ -4145,6 +4146,19 @@ static int add_prefix_symbol(struct objtool_file *file, struct symbol *func)
if (!prev)
return -1;

if (!insn->cfi) {
/*
* This can happen if stack validation isn't enabled or the
* function is annotated with STACK_FRAME_NON_STANDARD.
*/
return 0;
}

/* Propagate insn->cfi to the prefix code */
cfi = cfi_hash_find_or_add(insn->cfi);
for (; prev != insn; prev = next_insn_same_sec(file, prev))
prev->cfi = cfi;

return 0;
}

Expand Down

0 comments on commit 5743654

Please sign in to comment.