linux/tools/objtool
Josh Poimboeuf 3732710ff6 objtool: Improve rare switch jump table pattern detection
GCC 6 added a new switch statement jump table optimization which makes
objtool's life harder.  It looks like:

  mov [rodata addr],%reg1
  ... some instructions ...
  jmpq *(%reg1,%reg2,8)

The optimization is quite rare, but objtool still needs to be able to
identify the pattern so that it can follow all possible control flow
paths related to the switch statement.

In order to detect the pattern, objtool starts from the indirect jump
and scans backwards through the function until it finds the first
instruction in the pattern.  If it encounters an unconditional jump
along the way, it stops and considers the pattern to be not found.

As it turns out, unconditional jumps can happen, as long as they are
small forward jumps within the range being scanned.

This fixes the following warnings:

  drivers/infiniband/sw/rxe/rxe_comp.o: warning: objtool: rxe_completer()+0x2f4: sibling call from callable instruction with changed frame pointer
  drivers/infiniband/sw/rxe/rxe_resp.o: warning: objtool: rxe_responder()+0x10f: sibling call from callable instruction with changed frame pointer

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.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/8a9ed68ae1780e8d3963e4ee13f2f257fe3a3c33.1476393584.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-10-16 09:12:35 +02:00
..
arch/x86 objtool: Support '-mtune=atom' stack frame setup instruction 2016-10-11 10:35:45 +02:00
Documentation objtool: Detect falling through to the next function 2016-04-16 11:14:17 +02:00
.gitignore objtool: Add 'fixdep' to objtool/.gitignore 2016-07-27 11:07:11 +02:00
arch.h objtool: Add tool to perform compile-time stack metadata validation 2016-02-29 08:35:12 +01:00
Build tools build: Fix objtool build with ARCH=x86_64 2016-07-22 16:37:44 -03:00
builtin-check.c objtool: Improve rare switch jump table pattern detection 2016-10-16 09:12:35 +02:00
builtin.h objtool: Add tool to perform compile-time stack metadata validation 2016-02-29 08:35:12 +01:00
elf.c objtool: Add fallback from ELF_C_READ_MMAP to ELF_C_READ 2016-07-13 15:38:50 -03:00
elf.h objtool: Allow building with older libelf 2016-05-17 10:42:46 +02:00
Makefile objtool: Un-capitalize "Warning" for out-of-sync instruction decoder 2016-07-29 16:57:16 +02:00
objtool.c objtool: Add tool to perform compile-time stack metadata validation 2016-02-29 08:35:12 +01:00
special.c objtool: Add tool to perform compile-time stack metadata validation 2016-02-29 08:35:12 +01:00
special.h objtool: Add tool to perform compile-time stack metadata validation 2016-02-29 08:35:12 +01:00
warn.h objtool: Add tool to perform compile-time stack metadata validation 2016-02-29 08:35:12 +01:00