linux-stable/arch
Fangrui Song 90ceddcb49 bpf: Support llvm-objcopy for vmlinux BTF
Simplify gen_btf logic to make it work with llvm-objcopy. The existing
'file format' and 'architecture' parsing logic is brittle and does not
work with llvm-objcopy/llvm-objdump.

'file format' output of llvm-objdump>=11 will match GNU objdump, but
'architecture' (bfdarch) may not.

.BTF in .tmp_vmlinux.btf is non-SHF_ALLOC. Add the SHF_ALLOC flag
because it is part of vmlinux image used for introspection. C code
can reference the section via linker script defined __start_BTF and
__stop_BTF. This fixes a small problem that previous .BTF had the
SHF_WRITE flag (objcopy -I binary -O elf* synthesized .data).

Additionally, `objcopy -I binary` synthesized symbols
_binary__btf_vmlinux_bin_start and _binary__btf_vmlinux_bin_stop (not
used elsewhere) are replaced with more commonplace __start_BTF and
__stop_BTF.

Add 2>/dev/null because GNU objcopy (but not llvm-objcopy) warns
"empty loadable segment detected at vaddr=0xffffffff81000000, is this intentional?"

We use a dd command to change the e_type field in the ELF header from
ET_EXEC to ET_REL so that lld will accept .btf.vmlinux.bin.o.  Accepting
ET_EXEC as an input file is an extremely rare GNU ld feature that lld
does not intend to support, because this is error-prone.

The output section description .BTF in include/asm-generic/vmlinux.lds.h
avoids potential subtle orphan section placement issues and suppresses
--orphan-handling=warn warnings.

Fixes: df786c9b94 ("bpf: Force .BTF section start to zero when dumping from vmlinux")
Fixes: cb0cc635c7 ("powerpc: Include .BTF section")
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Fangrui Song <maskray@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Stanislav Fomichev <sdf@google.com>
Tested-by: Andrii Nakryiko <andriin@fb.com>
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Link: https://github.com/ClangBuiltLinux/linux/issues/871
Link: https://lore.kernel.org/bpf/20200318222746.173648-1-maskray@google.com
2020-03-19 12:32:38 +01:00
..
alpha Kbuild updates for v5.6 (2nd) 2020-02-09 16:05:50 -08:00
arc arc: mm: add p?d_leaf() definitions 2020-02-04 03:05:24 +00:00
arm ARM: socfpga_defconfig: add back DEBUGFS 2020-03-04 08:51:55 -08:00
arm64 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-03-12 16:19:19 -07:00
c6x Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-01-28 10:07:09 -08:00
csky csky: Replace <linux/clk-provider.h> by <linux/of_clk.h> 2020-02-23 12:48:55 +08:00
h8300 Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-01-28 10:07:09 -08:00
hexagon Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-01-28 10:07:09 -08:00
ia64 proc: convert everything to "struct proc_ops" 2020-02-04 03:05:26 +00:00
m68k Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu 2020-02-06 08:13:23 +00:00
microblaze Microblaze patches for 5.6-rc1 2020-02-04 11:58:07 +00:00
mips MIPS: DTS: CI20: fix interrupt for pcf8563 RTC 2020-03-07 09:54:24 +01:00
nds32 TTY/Serial driver updates for 5.6-rc1 2020-01-29 10:13:27 -08:00
nios2 TTY/Serial driver updates for 5.6-rc1 2020-01-29 10:13:27 -08:00
openrisc TTY/Serial driver updates for 5.6-rc1 2020-01-29 10:13:27 -08:00
parisc Merge branch 'parisc-5.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux 2020-02-05 07:29:40 +00:00
powerpc bpf: Support llvm-objcopy for vmlinux BTF 2020-03-19 12:32:38 +01:00
riscv Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2020-03-13 20:52:03 -07:00
s390 s390/pci: Fix unexpected write combine on resource 2020-03-04 11:18:03 +01:00
sh proc: convert everything to "struct proc_ops" 2020-02-04 03:05:26 +00:00
sparc Kbuild updates for v5.6 (2nd) 2020-02-09 16:05:50 -08:00
um um: reject unsupported coalescing params 2020-03-06 22:45:54 -08:00
unicore32 MPX requires recompiling applications, which requires compiler support. 2020-01-30 16:11:50 -08:00
x86 Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2020-03-13 20:52:03 -07:00
xtensa Xtensa updates for v5.6: 2020-02-07 12:22:29 -08:00
.gitignore
Kconfig arch/Kconfig: update HAVE_RELIABLE_STACKTRACE description 2020-03-06 07:06:09 -06:00