diff mbox series

[1/2] bpf: Fix build for disabled CONFIG_DEBUG_INFO_BTF option

Message ID 20200714102534.299280-1-jolsa@kernel.org
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [1/2] bpf: Fix build for disabled CONFIG_DEBUG_INFO_BTF option | expand

Commit Message

Jiri Olsa July 14, 2020, 10:25 a.m. UTC
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>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 include/linux/btf_ids.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Alexei Starovoitov July 14, 2020, 5:26 p.m. UTC | #1
On Tue, Jul 14, 2020 at 3:25 AM Jiri Olsa <jolsa@kernel.org> wrote:
>
> 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>
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Applied both to bpf-next. Thanks for the quick fix.
diff mbox series

Patch

diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h
index fe019774f8a7..b3c73db9587c 100644
--- a/include/linux/btf_ids.h
+++ b/include/linux/btf_ids.h
@@ -3,6 +3,8 @@ 
 #ifndef _LINUX_BTF_IDS_H
 #define _LINUX_BTF_IDS_H
 
+#ifdef CONFIG_DEBUG_INFO_BTF
+
 #include <linux/compiler.h> /* for __PASTE */
 
 /*
@@ -83,5 +85,12 @@  asm(							\
 ".zero 4                                       \n"	\
 ".popsection;                                  \n");
 
+#else
+
+#define BTF_ID_LIST(name) static u32 name[5];
+#define BTF_ID(prefix, name)
+#define BTF_ID_UNUSED
+
+#endif /* CONFIG_DEBUG_INFO_BTF */
 
 #endif