Skip to content

Commit 3c1f058

Browse files
jpoimboeIngo Molnar
authored andcommitted
objtool: Add Clang support
Since the ORC unwinder was made the default on x86_64, Clang-built defconfig kernels have triggered some new objtool warnings: drivers/gpu/drm/i915/i915_gpu_error.o: warning: objtool: i915_error_printf()+0x6c: return with modified stack frame drivers/gpu/drm/i915/intel_display.o: warning: objtool: pipe_config_err()+0xa6: return with modified stack frame The problem is that objtool has never seen clang-built binaries before. Shockingly enough, objtool is apparently able to follow the code flow mostly fine, except for one instruction sequence. Instead of a LEAVE instruction, clang restores RSP and RBP the long way: 67c: 48 89 ec mov %rbp,%rsp 67f: 5d pop %rbp Teach objtool about this new code sequence. Reported-and-test-by: Matthias Kaehlcke <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Matthias Kaehlcke <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/fce88ce81c356eedcae7f00ed349cfaddb3363cc.1521741586.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <[email protected]>
1 parent d8ba61b commit 3c1f058

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/objtool/check.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,17 @@ static int update_insn_state(struct instruction *insn, struct insn_state *state)
13861386
state->vals[op->dest.reg].offset = -state->stack_size;
13871387
}
13881388

1389+
else if (op->src.reg == CFI_BP && op->dest.reg == CFI_SP &&
1390+
cfa->base == CFI_BP) {
1391+
1392+
/*
1393+
* mov %rbp, %rsp
1394+
*
1395+
* Restore the original stack pointer (Clang).
1396+
*/
1397+
state->stack_size = -state->regs[CFI_BP].offset;
1398+
}
1399+
13891400
else if (op->dest.reg == cfa->base) {
13901401

13911402
/* mov %reg, %rsp */

0 commit comments

Comments
 (0)