1
0
Fork 0
remarkable-linux/tools/objtool
Josh Poimboeuf 0bcba95686 objtool: Support GCC 8 '-fnoreorder-functions'
[ Upstream commit 08b393d01c ]

Since the following commit:

  cd77849a69 ("objtool: Fix GCC 8 cold subfunction detection for aliased functions")

... if the kernel is built with EXTRA_CFLAGS='-fno-reorder-functions',
objtool can get stuck in an infinite loop.

That flag causes the new GCC 8 cold subfunctions to be placed in .text
instead of .text.unlikely.  But it also has an unfortunate quirk: in the
symbol table, the subfunction (e.g., nmi_panic.cold.7) is nested inside
the parent (nmi_panic).

That function overlap confuses objtool, and causes it to get into an
infinite loop in next_insn_same_func().  Here's Allan's description of
the loop:

  "Objtool iterates through the instructions in nmi_panic using
  next_insn_same_func. Once it reaches the end of nmi_panic at 0x534 it
  jumps to 0x528 as that's the start of nmi_panic.cold.7. However, since
  the instructions starting at 0x528 are still associated with nmi_panic
  objtool will get stuck in a loop, continually jumping back to 0x528
  after reaching 0x534."

Fix it by shortening the length of the parent function so that the
functions no longer overlap.

Reported-and-analyzed-by: Allan Xavier <allan.x.xavier@oracle.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Allan Xavier <allan.x.xavier@oracle.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/9e704c52bee651129b036be14feda317ae5606ae.1530136978.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-24 13:09:11 +02:00
..
Documentation x86/asm: Fix inline asm call constraints for Clang 2017-09-23 15:06:20 +02:00
arch/x86 objtool, kprobes/x86: Sync the latest <asm/insn.h> header with tools/objtool/arch/x86/include/asm/insn.h 2018-06-21 04:02:58 +09:00
.gitignore objtool: Move synced files to their original relative locations 2017-12-29 17:53:41 +01:00
Build objtool: Add ORC unwind table generation 2017-07-18 10:57:43 +02:00
Makefile Kbuild: fix # escaping in .cmd files for future Make 2018-07-11 16:29:21 +02:00
arch.h objtool: Assume unannotated UD2 instructions are dead ends 2017-07-28 08:33:32 +02:00
builtin-check.c objtool: Add module specific retpoline rules 2018-03-15 10:54:38 +01:00
builtin-orc.c objtool: Use existing global variables for options 2018-03-15 10:54:37 +01:00
builtin.h objtool: Add module specific retpoline rules 2018-03-15 10:54:38 +01:00
cfi.h objtool: Handle GCC stack pointer adjustment bug 2017-08-30 10:48:41 +02:00
check.c objtool: Fix "noreturn" detection for recursive sibling calls 2018-06-05 11:41:55 +02:00
check.h objtool: Add retpoline validation 2018-03-15 10:54:37 +01:00
elf.c objtool: Support GCC 8 '-fnoreorder-functions' 2018-08-24 13:09:11 +02:00
elf.h objtool: Support GCC 8's cold subfunctions 2018-06-05 11:41:54 +02:00
objtool.c objtool: Print top level commands on incorrect usage 2017-12-25 14:26:14 +01:00
orc.h objtool: Move synced files to their original relative locations 2017-12-29 17:53:41 +01:00
orc_dump.c objtool: Fix 64-bit build on 32-bit host 2017-12-29 17:53:42 +01:00
orc_gen.c objtool: Warn on stripped section symbol 2018-02-07 11:12:21 -08: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
sync-check.sh objtool: Move kernel headers/code sync check to a script 2017-12-29 17:53:42 +01:00
warn.h objtool: Implement stack validation 2.0 2017-06-30 10:19:19 +02:00