Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: Fix cross build for CONFIG_DEBUG_INFO_BTF option

Stephen and 0-DAY CI Kernel Test Service reported broken cross build
for arm (arm-linux-gnueabi-gcc (GCC) 9.3.0), with following output:

/tmp/ccMS5uth.s: Assembler messages:
/tmp/ccMS5uth.s:69: Error: unrecognized symbol type ""
/tmp/ccMS5uth.s:82: Error: unrecognized symbol type ""

Having '@object' for .type diretive is wrong because '@' is comment
character for some architectures. Using STT_OBJECT instead that should
work everywhere.

Also using HOST* variables to build resolve_btfids so it's properly
build in crossbuilds (stolen from objtool's Makefile).

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/bpf/20200714102534.299280-2-jolsa@kernel.org

authored by

Jiri Olsa and committed by
Alexei Starovoitov
11bb2f7a 079ef536

+15 -1
+1 -1
include/linux/btf_ids.h
··· 23 23 asm( \ 24 24 ".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \ 25 25 ".local " #symbol " ; \n" \ 26 - ".type " #symbol ", @object; \n" \ 26 + ".type " #symbol ", STT_OBJECT; \n" \ 27 27 ".size " #symbol ", 4; \n" \ 28 28 #symbol ": \n" \ 29 29 ".zero 4 \n" \
+14
tools/bpf/resolve_btfids/Makefile
··· 16 16 MAKEFLAGS=--no-print-directory 17 17 endif 18 18 19 + # always use the host compiler 20 + ifneq ($(LLVM),) 21 + HOSTAR ?= llvm-ar 22 + HOSTCC ?= clang 23 + HOSTLD ?= ld.lld 24 + else 25 + HOSTAR ?= ar 26 + HOSTCC ?= gcc 27 + HOSTLD ?= ld 28 + endif 29 + AR = $(HOSTAR) 30 + CC = $(HOSTCC) 31 + LD = $(HOSTLD) 32 + 19 33 OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/ 20 34 21 35 LIBBPF_SRC := $(srctree)/tools/lib/bpf/