kernel_optimize_test/arch/powerpc/kernel
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
..
syscalls
trace
vdso32
vdso64
.gitignore
align.c
asm-offsets.c
audit.c
btext.c
cacheinfo.c
cacheinfo.h
compat_audit.c
cpu_setup_6xx.S
cpu_setup_44x.S
cpu_setup_fsl_booke.S
cpu_setup_pa6t.S
cpu_setup_power.S
cpu_setup_ppc970.S
cputable.c
crash_dump.c
dawr.c
dbell.c
dma-iommu.c
dma-mask.c
dma-swiotlb.c
dt_cpu_ftrs.c
early_32.c
eeh_cache.c
eeh_dev.c
eeh_driver.c
eeh_event.c
eeh_pe.c
eeh_sysfs.c
eeh.c
entry_32.S
entry_64.S
epapr_hcalls.S
epapr_paravirt.c
exceptions-64e.S
exceptions-64s.S
fadump.c
firmware.c
fpu.S
fsl_booke_entry_mapping.S
head_8xx.S
head_32.h
head_32.S
head_40x.S
head_44x.S
head_64.S
head_booke.h
head_fsl_booke.S
hw_breakpoint.c
idle_6xx.S
idle_book3e.S
idle_book3s.S
idle_e500.S
idle.c
ima_arch.c
io-workarounds.c
io.c
iomap.c
iommu.c
irq.c
isa-bridge.c
jump_label.c
kgdb.c
kprobes-ftrace.c
kprobes.c
kvm_emul.S
kvm.c
l2cr_6xx.S
legacy_serial.c
Makefile
mce_power.c
mce.c
misc_32.S
misc_64.S
misc.S
module_32.c
module_64.c
module.c
module.lds
msi.c
note.S
nvram_64.c
of_platform.c
optprobes_head.S
optprobes.c
paca.c
pci_32.c
pci_64.c
pci_dn.c
pci_of_scan.c
pci-common.c
pci-hotplug.c
pmc.c
ppc_save_regs.S
ppc32.h
proc_powerpc.c
process.c
prom_init_check.sh
prom_init.c
prom_parse.c
prom.c
ptrace.c
ptrace32.c
reloc_32.S
reloc_64.S
rtas_flash.c
rtas_pci.c
rtas-proc.c
rtas-rtc.c
rtas.c
rtasd.c
secure_boot.c
security.c
secvar-ops.c
secvar-sysfs.c
setup_32.c
setup_64.c
setup-common.c
setup.h
signal_32.c
signal_64.c
signal.c
signal.h
smp-tbsync.c
smp.c
stacktrace.c
suspend.c
swsusp_32.S
swsusp_64.c
swsusp_asm64.S
swsusp_booke.S
swsusp.c
sys_ppc32.c
syscalls.c
sysfs.c
systbl_chk.sh
systbl.S
tau_6xx.c
time.c
tm.S
traps.c
ucall.S
udbg_16550.c
udbg.c
uprobes.c
vdso.c
vecemu.c
vector.S
vmlinux.lds.S
watchdog.c