• Josh Poimboeuf's avatar
    objtool: Fix function fallthrough detection · 01cdbf42
    Josh Poimboeuf authored
    commit e6f393bc upstream.
    
    When a function falls through to the next function due to a compiler
    bug, objtool prints some obscure warnings.  For example:
    
      drivers/regulator/core.o: warning: objtool: regulator_count_voltages()+0x95: return with modified stack frame
      drivers/regulator/core.o: warning: objtool: regulator_count_voltages()+0x0: stack state mismatch: cfa1=7+32 cfa2=7+8
    
    Instead it should be printing:
    
      drivers/regulator/core.o: warning: objtool: regulator_supply_is_couple() falls through to next function regulator_count_voltages()
    
    This used to work, but was broken by the following commit:
    
      13810435 ("objtool: Support GCC 8's cold subfunctions")
    
    The padding nops at the end of a function aren't actually part of the
    function, as defined by the symbol table.  So the 'func' variable in
    validate_branch() is getting cleared to NULL when a padding nop is
    encountered, breaking the fallthrough detection.
    
    If the current instruction doesn't have a function associated with it,
    just consider it to be part of the previously detected function by not
    overwriting the previous value of 'func'.
    Reported-by: default avatarkbuild test robot <lkp@intel.com>
    Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: <stable@vger.kernel.org>
    Fixes: 13810435 ("objtool: Support GCC 8's cold subfunctions")
    Link: http://lkml.kernel.org/r/546d143820cd08a46624ae8440d093dd6c902cae.1557766718.git.jpoimboe@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    01cdbf42
check.c 53.5 KB