linux/tools/objtool
Josh Poimboeuf dd88a0a0c8 objtool: Handle GCC stack pointer adjustment bug
Arnd Bergmann reported the following warning with GCC 7.1.1:

  fs/fs_pin.o: warning: objtool: pin_kill()+0x139: stack state mismatch: cfa1=7+88 cfa2=7+96

And the kbuild robot reported the following warnings with GCC 5.4.1:

  fs/fs_pin.o: warning: objtool: pin_kill()+0x182: return with modified stack frame
  fs/quota/dquot.o: warning: objtool: dquot_alloc_inode()+0x140: stack state mismatch: cfa1=7+120 cfa2=7+128
  fs/quota/dquot.o: warning: objtool: dquot_free_inode()+0x11a: stack state mismatch: cfa1=7+112 cfa2=7+120

Those warnings are caused by an unusual GCC non-optimization where it
uses an intermediate register to adjust the stack pointer.  It does:

  lea    0x8(%rsp), %rcx
  ...
  mov    %rcx, %rsp

Instead of the obvious:

  add    $0x8, %rsp

It makes no sense to use an intermediate register, so I opened a GCC bug
to track it:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81813

But it's not exactly a high-priority bug and it looks like we'll be
stuck with this issue for a while.  So for now we have to track register
values when they're loaded with stack pointer offsets.

This is kind of a big workaround for a tiny problem, but c'est la vie.
I hope to eventually create a GCC plugin to implement a big chunk of
objtool's functionality.  Hopefully at that point we'll be able to
remove of a lot of these GCC-isms from the objtool code.

Reported-by: Arnd Bergmann <arnd@arndb.de>
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/6a41a96884c725e7f05413bb7df40cfe824b2444.1504028945.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-30 10:48:41 +02:00
..
arch/x86 objtool: Handle GCC stack pointer adjustment bug 2017-08-30 10:48:41 +02:00
Documentation objtool: Add ORC unwind table generation 2017-07-18 10:57:43 +02:00
.gitignore objtool: Add 'fixdep' to objtool/.gitignore 2016-07-27 11:07:11 +02:00
arch.h objtool: Assume unannotated UD2 instructions are dead ends 2017-07-28 08:33:32 +02:00
Build objtool: Add ORC unwind table generation 2017-07-18 10:57:43 +02:00
builtin-check.c objtool: Fix gcov check for older versions of GCC 2017-07-25 11:12:45 +02:00
builtin-orc.c objtool: Fix gcov check for older versions of GCC 2017-07-25 11:12:45 +02:00
builtin.h objtool: Add ORC unwind table generation 2017-07-18 10:57:43 +02:00
cfi.h objtool: Handle GCC stack pointer adjustment bug 2017-08-30 10:48:41 +02:00
check.c objtool: Handle GCC stack pointer adjustment bug 2017-08-30 10:48:41 +02:00
check.h objtool: Handle GCC stack pointer adjustment bug 2017-08-30 10:48:41 +02:00
elf.c objtool: Add ORC unwind table generation 2017-07-18 10:57:43 +02:00
elf.h objtool: Add ORC unwind table generation 2017-07-18 10:57:43 +02:00
Makefile objtool: Disable GCC '-Wpacked' warnings 2017-07-28 08:33:32 +02:00
objtool.c objtool: Add ORC unwind table generation 2017-07-18 10:57:43 +02:00
orc_dump.c objtool: Add ORC unwind table generation 2017-07-18 10:57:43 +02:00
orc_gen.c objtool: Add ORC unwind table generation 2017-07-18 10:57:43 +02:00
orc_types.h objtool, x86: Add facility for asm code to provide unwind hints 2017-07-18 10:57:44 +02:00
orc.h objtool: Add ORC unwind table generation 2017-07-18 10:57:43 +02:00
special.c objtool: Implement stack validation 2.0 2017-06-30 10:19:19 +02:00
special.h objtool: Add tool to perform compile-time stack metadata validation 2016-02-29 08:35:12 +01:00
warn.h objtool: Implement stack validation 2.0 2017-06-30 10:19:19 +02:00