linux/include/asm-generic
Fangrui Song f04d1e880f bpf: Support llvm-objcopy for vmlinux BTF
commit 90ceddcb49 upstream.

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
Signed-off-by: Maria Teguiani <teguiani@google.com>
Tested-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-06-17 16:40:20 +02:00
..
bitops
vdso
4level-fixup.h
5level-fixup.h
Kbuild
asm-offsets.h
asm-prototypes.h
atomic-instrumented.h
atomic-long.h
atomic.h
atomic64.h
audit_change_attr.h
audit_dir_write.h
audit_read.h
audit_signal.h
audit_write.h
barrier.h
bitops-instrumented.h
bitops.h
bitsperlong.h
bug.h
bugs.h
cache.h
cacheflush.h
checksum.h
cmpxchg-local.h
cmpxchg.h
compat.h
current.h
delay.h
device.h
div64.h
dma-contiguous.h
dma-mapping.h
dma.h
early_ioremap.h
emergency-restart.h
error-injection.h
exec.h
export.h
extable.h
fb.h
fixmap.h
flat.h
ftrace.h
futex.h
getorder.h
gpio.h
hardirq.h
hugetlb.h
hw_irq.h
ide_iops.h
int-ll64.h
io.h
ioctl.h
iomap.h
irq.h
irq_regs.h
irq_work.h
irqflags.h
kdebug.h
kmap_types.h
kprobes.h
kvm_para.h
linkage.h
local.h
local64.h
mcs_spinlock.h
memory_model.h
mm-arch-hooks.h
mm_hooks.h
mmiowb.h
mmiowb_types.h
mmu.h
mmu_context.h
module.h
mshyperv.h
msi.h
page.h
param.h
parport.h
pci.h
pci_iomap.h
percpu.h
pgalloc.h
pgtable-nop4d-hack.h
pgtable-nop4d.h
pgtable-nopmd.h
pgtable-nopud.h
pgtable.h
preempt.h
qrwlock.h
qrwlock_types.h
qspinlock.h
qspinlock_types.h
resource.h
seccomp.h
sections.h
serial.h
set_memory.h
shmparam.h
signal.h
simd.h
spinlock.h
statfs.h
string.h
switch_to.h
syscall.h
syscalls.h
termios-base.h
termios.h
timex.h
tlb.h
tlbflush.h
topology.h include/asm-generic/topology.h: guard cpumask_of_node() macro argument 2020-06-03 08:21:27 +02:00
trace_clock.h
uaccess.h
unaligned.h
user.h
vga.h
vmlinux.lds.h bpf: Support llvm-objcopy for vmlinux BTF 2020-06-17 16:40:20 +02:00
vtime.h
word-at-a-time.h
xor.h