Skip to content

Commit

Permalink
tools/bpf: Sync btf_ids.h to tools
Browse files Browse the repository at this point in the history
Sync kernel header btf_ids.h to tools directory.
Also define macro CONFIG_DEBUG_INFO_BTF before
including btf_ids.h in prog_tests/resolve_btfids.c
since non-stub definitions for BTF_ID_LIST etc. macros
are defined under CONFIG_DEBUG_INFO_BTF. This
prevented test_progs from failing.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200720163359.1393079-1-yhs@fb.com
  • Loading branch information
Yonghong Song authored and Alexei Starovoitov committed Jul 21, 2020
1 parent bc4f054 commit d8dfe5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/include/linux/btf_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

/*
Expand All @@ -21,7 +23,7 @@
asm( \
".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
".local " #symbol " ; \n" \
".type " #symbol ", @object; \n" \
".type " #symbol ", STT_OBJECT; \n" \
".size " #symbol ", 4; \n" \
#symbol ": \n" \
".zero 4 \n" \
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions tools/testing/selftests/bpf/prog_tests/resolve_btfids.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <bpf/libbpf.h>
#include <linux/btf.h>
#include <linux/kernel.h>
#define CONFIG_DEBUG_INFO_BTF
#include <linux/btf_ids.h>
#include "test_progs.h"

Expand Down

0 comments on commit d8dfe5b

Please sign in to comment.