OSDN Git Service

tools/bpf: expose functions btf_ext__* as API functions
authorYonghong Song <yhs@fb.com>
Mon, 4 Feb 2019 19:00:57 +0000 (11:00 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 4 Feb 2019 20:48:36 +0000 (12:48 -0800)
The following set of functions, which manipulates .BTF.ext
section, are exposed as API functions:
  . btf_ext__new
  . btf_ext__free
  . btf_ext__reloc_func_info
  . btf_ext__reloc_line_info
  . btf_ext__func_info_rec_size
  . btf_ext__line_info_rec_size

These functions are useful for JIT based bpf codegen, e.g.,
bcc, to manipulate in-memory .BTF.ext sections.

The signature of function btf_ext__reloc_func_info()
is also changed to be the same as its definition in btf.c.

Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/btf.h
tools/lib/bpf/libbpf.map

index b1e8e54..418389e 100644 (file)
@@ -67,18 +67,18 @@ LIBBPF_API int btf__fd(const struct btf *btf);
 LIBBPF_API const char *btf__name_by_offset(const struct btf *btf, __u32 offset);
 LIBBPF_API int btf__get_from_id(__u32 id, struct btf **btf);
 
-struct btf_ext *btf_ext__new(__u8 *data, __u32 size);
-void btf_ext__free(struct btf_ext *btf_ext);
-int btf_ext__reloc_func_info(const struct btf *btf,
-                            const struct btf_ext *btf_ext,
-                            const char *sec_name, __u32 insns_cnt,
-                            void **func_info, __u32 *func_info_len);
-int btf_ext__reloc_line_info(const struct btf *btf,
-                            const struct btf_ext *btf_ext,
-                            const char *sec_name, __u32 insns_cnt,
-                            void **line_info, __u32 *cnt);
-__u32 btf_ext__func_info_rec_size(const struct btf_ext *btf_ext);
-__u32 btf_ext__line_info_rec_size(const struct btf_ext *btf_ext);
+LIBBPF_API struct btf_ext *btf_ext__new(__u8 *data, __u32 size);
+LIBBPF_API void btf_ext__free(struct btf_ext *btf_ext);
+LIBBPF_API int btf_ext__reloc_func_info(const struct btf *btf,
+                                       const struct btf_ext *btf_ext,
+                                       const char *sec_name, __u32 insns_cnt,
+                                       void **func_info, __u32 *cnt);
+LIBBPF_API int btf_ext__reloc_line_info(const struct btf *btf,
+                                       const struct btf_ext *btf_ext,
+                                       const char *sec_name, __u32 insns_cnt,
+                                       void **line_info, __u32 *cnt);
+LIBBPF_API __u32 btf_ext__func_info_rec_size(const struct btf_ext *btf_ext);
+LIBBPF_API __u32 btf_ext__line_info_rec_size(const struct btf_ext *btf_ext);
 
 #ifdef __cplusplus
 } /* extern "C" */
index 62c680f..46441c5 100644 (file)
@@ -133,4 +133,10 @@ LIBBPF_0.0.2 {
                bpf_map_lookup_elem_flags;
                bpf_object__find_map_fd_by_name;
                bpf_get_link_xdp_id;
+               btf_ext__free;
+               btf_ext__func_info_rec_size;
+               btf_ext__line_info_rec_size;
+               btf_ext__new;
+               btf_ext__reloc_func_info;
+               btf_ext__reloc_line_info;
 } LIBBPF_0.0.1;