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

bpf: Fix build for disabled CONFIG_DEBUG_INFO_BTF option

Stephen reported following linker warnings on powerpc build:

ld: warning: orphan section `.BTF_ids' from `kernel/trace/bpf_trace.o' being placed in section `.BTF_ids'
ld: warning: orphan section `.BTF_ids' from `kernel/bpf/btf.o' being placed in section `.BTF_ids'
ld: warning: orphan section `.BTF_ids' from `kernel/bpf/stackmap.o' being placed in section `.BTF_ids'
ld: warning: orphan section `.BTF_ids' from `net/core/filter.o' being placed in section `.BTF_ids'
ld: warning: orphan section `.BTF_ids' from `kernel/trace/bpf_trace.o' being placed in section `.BTF_ids'

It's because we generated .BTF_ids section even when
CONFIG_DEBUG_INFO_BTF is not enabled. Fixing this by
generating empty btf_id arrays for this case.

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-1-jolsa@kernel.org

authored by

Jiri Olsa and committed by
Alexei Starovoitov
079ef536 f7d40ee7

+9
+9
include/linux/btf_ids.h
··· 3 3 #ifndef _LINUX_BTF_IDS_H 4 4 #define _LINUX_BTF_IDS_H 5 5 6 + #ifdef CONFIG_DEBUG_INFO_BTF 7 + 6 8 #include <linux/compiler.h> /* for __PASTE */ 7 9 8 10 /* ··· 85 83 ".zero 4 \n" \ 86 84 ".popsection; \n"); 87 85 86 + #else 87 + 88 + #define BTF_ID_LIST(name) static u32 name[5]; 89 + #define BTF_ID(prefix, name) 90 + #define BTF_ID_UNUSED 91 + 92 + #endif /* CONFIG_DEBUG_INFO_BTF */ 88 93 89 94 #endif