bpf: Add BTF_ID_LIST/BTF_ID/BTF_ID_UNUSED macros
authorJiri Olsa <jolsa@kernel.org>
Sat, 11 Jul 2020 21:53:23 +0000 (23:53 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 13 Jul 2020 17:42:02 +0000 (10:42 -0700)
commit5a2798ab32ba2952cfe25701ee460bccbd434c75
tree129a8daa75fe60daa836cdf4de8a5418311de5a9
parent33a57ce0a54d498275f432db04850001175dfdfa
bpf: Add BTF_ID_LIST/BTF_ID/BTF_ID_UNUSED macros

Adding support to generate .BTF_ids section that will hold BTF
ID lists for verifier.

Adding macros that will help to define lists of BTF ID values
placed in .BTF_ids section. They are initially filled with zeros
(during compilation) and resolved later during the linking phase
by resolve_btfids tool.

Following defines list of one BTF ID value:

  BTF_ID_LIST(bpf_skb_output_btf_ids)
  BTF_ID(struct, sk_buff)

It also defines following variable to access the list:

  extern u32 bpf_skb_output_btf_ids[];

The BTF_ID_UNUSED macro defines 4 zero bytes. It's used when we
want to define 'unused' entry in BTF_ID_LIST, like:

  BTF_ID_LIST(bpf_skb_output_btf_ids)
  BTF_ID(struct, sk_buff)
  BTF_ID_UNUSED
  BTF_ID(struct, task_struct)

Suggested-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200711215329.41165-4-jolsa@kernel.org
include/asm-generic/vmlinux.lds.h
include/linux/btf_ids.h [new file with mode: 0644]