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

objtool: Fix objtool fallthrough detection with function padding

When GCC adds NOP padding between functions, those NOPs aren't
associated with a function symbol, which breaks objtool's detection of a
function falling through to another function. Instead it shows
confusing errors like:

drivers/mtd/chips/cfi_util.o: warning: objtool: cfi_qry_mode_on()+0x8b: return with modified stack frame
drivers/mtd/chips/cfi_util.o: warning: objtool: cfi_qry_mode_on()+0x0: stack state mismatch: cfa1=-4-32 cfa2=7+8
drivers/mtd/chips/cfi_cmdset_0002.o: warning: objtool: fixup_use_fwh_lock()+0x8: unknown stack-related register move
drivers/mtd/chips/cfi_cmdset_0002.o: warning: objtool: fixup_use_fwh_lock()+0x0: stack state mismatch: cfa1=6+16 cfa2=7+8
drivers/mtd/chips/cfi_cmdset_0002.o: warning: objtool: do_otp_write()+0xa: unsupported stack pointer realignment
drivers/mtd/chips/cfi_cmdset_0002.o: warning: objtool: do_otp_write()+0x0: stack state mismatch: cfa1=-4-40 cfa2=7+8

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/43e7aae9a7a7710cd6df597fa9dc501da4ba0602.1502472193.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Josh Poimboeuf and committed by
Ingo Molnar
ee97638b fa2016a8

+7 -7
+7 -7
tools/objtool/check.c
··· 1536 1536 while (1) { 1537 1537 next_insn = next_insn_same_sec(file, insn); 1538 1538 1539 - if (file->c_file && insn->func) { 1540 - if (func && func != insn->func) { 1541 - WARN("%s() falls through to next function %s()", 1542 - func->name, insn->func->name); 1543 - return 1; 1544 - } 1539 + 1540 + if (file->c_file && func && insn->func && func != insn->func) { 1541 + WARN("%s() falls through to next function %s()", 1542 + func->name, insn->func->name); 1543 + return 1; 1545 1544 } 1546 1545 1547 - func = insn->func; 1546 + if (insn->func) 1547 + func = insn->func; 1548 1548 1549 1549 if (func && insn->ignore) { 1550 1550 WARN_FUNC("BUG: why am I validating an ignored function?",