Skip to content

Commit 5743654

Browse files
jpoimboePeter Zijlstra
authored andcommitted
objtool: Generate ORC data for __pfx code
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
1 parent 4a2c344 commit 5743654

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tools/objtool/check.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4117,6 +4117,7 @@ static bool ignore_unreachable_insn(struct objtool_file *file, struct instructio
41174117
static int add_prefix_symbol(struct objtool_file *file, struct symbol *func)
41184118
{
41194119
struct instruction *insn, *prev;
4120+
struct cfi_state *cfi;
41204121

41214122
insn = find_insn(file, func->sec, func->offset);
41224123
if (!insn)
@@ -4145,6 +4146,19 @@ static int add_prefix_symbol(struct objtool_file *file, struct symbol *func)
41454146
if (!prev)
41464147
return -1;
41474148

4149+
if (!insn->cfi) {
4150+
/*
4151+
* This can happen if stack validation isn't enabled or the
4152+
* function is annotated with STACK_FRAME_NON_STANDARD.
4153+
*/
4154+
return 0;
4155+
}
4156+
4157+
/* Propagate insn->cfi to the prefix code */
4158+
cfi = cfi_hash_find_or_add(insn->cfi);
4159+
for (; prev != insn; prev = next_insn_same_sec(file, prev))
4160+
prev->cfi = cfi;
4161+
41484162
return 0;
41494163
}
41504164

0 commit comments

Comments
 (0)