Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Josh Poimboeuf and committed by
Peter Zijlstra
5743654f 4a2c3448

+14
+14
tools/objtool/check.c
··· 4117 4117 static int add_prefix_symbol(struct objtool_file *file, struct symbol *func) 4118 4118 { 4119 4119 struct instruction *insn, *prev; 4120 + struct cfi_state *cfi; 4120 4121 4121 4122 insn = find_insn(file, func->sec, func->offset); 4122 4123 if (!insn) ··· 4145 4144 4146 4145 if (!prev) 4147 4146 return -1; 4147 + 4148 + if (!insn->cfi) { 4149 + /* 4150 + * This can happen if stack validation isn't enabled or the 4151 + * function is annotated with STACK_FRAME_NON_STANDARD. 4152 + */ 4153 + return 0; 4154 + } 4155 + 4156 + /* Propagate insn->cfi to the prefix code */ 4157 + cfi = cfi_hash_find_or_add(insn->cfi); 4158 + for (; prev != insn; prev = next_insn_same_sec(file, prev)) 4159 + prev->cfi = cfi; 4148 4160 4149 4161 return 0; 4150 4162 }