linux-stable/tools/objtool
Josh Poimboeuf 37ffdca816 objtool: Support Clang non-section symbols in ORC generation
commit e81e072443 upstream.

When compiling the kernel with AS=clang, objtool produces a lot of
warnings:

  warning: objtool: missing symbol for section .text
  warning: objtool: missing symbol for section .init.text
  warning: objtool: missing symbol for section .ref.text

It then fails to generate the ORC table.

The problem is that objtool assumes text section symbols always exist.
But the Clang assembler is aggressive about removing them.

When generating relocations for the ORC table, objtool always tries to
reference instructions by their section symbol offset.  If the section
symbol doesn't exist, it bails.

Do a fallback: when a section symbol isn't available, reference a
function symbol instead.

Reported-by: Dmitry Golovin <dima@golovin.in>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://github.com/ClangBuiltLinux/linux/issues/669
Link: https://lkml.kernel.org/r/9a9cae7fcf628843aabe5a086b1a3c5bf50f42e8.1585761021.git.jpoimboe@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-10 09:12:08 +01:00
..
arch/x86 x86/uprobes: Do not use prefixes.nbytes when looping over prefixes.bytes 2020-12-11 13:39:07 +01:00
Documentation x86/asm: Fix inline asm call constraints for Clang 2017-09-23 15:06:20 +02:00
.gitignore objtool: Move synced files to their original relative locations 2017-12-29 17:53:41 +01: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: 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 ignored functions 2020-10-01 13:12:49 +02:00
check.h objtool: Support per-function rodata sections 2019-06-25 11:36:50 +08:00
elf.c objtool: Don't fail on missing symbol table 2021-02-07 14:47:41 +01:00
elf.h objtool: Support per-function rodata sections 2019-06-25 11:36:50 +08:00
Makefile objtool: Clobber user CFLAGS variable 2019-10-05 12:47:35 +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: Support Clang non-section symbols in ORC dump 2020-05-02 17:24:44 +02:00
orc_gen.c objtool: Support Clang non-section symbols in ORC generation 2021-02-10 09:12:08 +01:00
special.c objtool: Implement stack validation 2.0 2017-06-30 10:19:19 +02:00
special.h
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