Skip to content

Commit 28b93c6

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
libbpf: Clean up and improve CO-RE reloc logging
Add logging of local/target type kind (struct/union/typedef/etc). Preserve unresolved root type ID (for cases of typedef). Improve the format of CO-RE reloc spec output format to contain only relevant and succinct info. Signed-off-by: Andrii Nakryiko <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 81ba088 commit 28b93c6

File tree

4 files changed

+169
-129
lines changed

4 files changed

+169
-129
lines changed

tools/lib/bpf/btf.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,14 +1131,14 @@ static int btf_ext_setup_line_info(struct btf_ext *btf_ext)
11311131
return btf_ext_setup_info(btf_ext, &param);
11321132
}
11331133

1134-
static int btf_ext_setup_field_reloc(struct btf_ext *btf_ext)
1134+
static int btf_ext_setup_core_relos(struct btf_ext *btf_ext)
11351135
{
11361136
struct btf_ext_sec_setup_param param = {
1137-
.off = btf_ext->hdr->field_reloc_off,
1138-
.len = btf_ext->hdr->field_reloc_len,
1139-
.min_rec_size = sizeof(struct bpf_field_reloc),
1140-
.ext_info = &btf_ext->field_reloc_info,
1141-
.desc = "field_reloc",
1137+
.off = btf_ext->hdr->core_relo_off,
1138+
.len = btf_ext->hdr->core_relo_len,
1139+
.min_rec_size = sizeof(struct bpf_core_relo),
1140+
.ext_info = &btf_ext->core_relo_info,
1141+
.desc = "core_relo",
11421142
};
11431143

11441144
return btf_ext_setup_info(btf_ext, &param);
@@ -1217,10 +1217,9 @@ struct btf_ext *btf_ext__new(__u8 *data, __u32 size)
12171217
if (err)
12181218
goto done;
12191219

1220-
if (btf_ext->hdr->hdr_len <
1221-
offsetofend(struct btf_ext_header, field_reloc_len))
1220+
if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, core_relo_len))
12221221
goto done;
1223-
err = btf_ext_setup_field_reloc(btf_ext);
1222+
err = btf_ext_setup_core_relos(btf_ext);
12241223
if (err)
12251224
goto done;
12261225

tools/lib/bpf/btf.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,6 @@ struct btf_type;
2424

2525
struct bpf_object;
2626

27-
/*
28-
* The .BTF.ext ELF section layout defined as
29-
* struct btf_ext_header
30-
* func_info subsection
31-
*
32-
* The func_info subsection layout:
33-
* record size for struct bpf_func_info in the func_info subsection
34-
* struct btf_sec_func_info for section #1
35-
* a list of bpf_func_info records for section #1
36-
* where struct bpf_func_info mimics one in include/uapi/linux/bpf.h
37-
* but may not be identical
38-
* struct btf_sec_func_info for section #2
39-
* a list of bpf_func_info records for section #2
40-
* ......
41-
*
42-
* Note that the bpf_func_info record size in .BTF.ext may not
43-
* be the same as the one defined in include/uapi/linux/bpf.h.
44-
* The loader should ensure that record_size meets minimum
45-
* requirement and pass the record as is to the kernel. The
46-
* kernel will handle the func_info properly based on its contents.
47-
*/
48-
struct btf_ext_header {
49-
__u16 magic;
50-
__u8 version;
51-
__u8 flags;
52-
__u32 hdr_len;
53-
54-
/* All offsets are in bytes relative to the end of this header */
55-
__u32 func_info_off;
56-
__u32 func_info_len;
57-
__u32 line_info_off;
58-
__u32 line_info_len;
59-
60-
/* optional part of .BTF.ext header */
61-
__u32 field_reloc_off;
62-
__u32 field_reloc_len;
63-
};
64-
6527
LIBBPF_API void btf__free(struct btf *btf);
6628
LIBBPF_API struct btf *btf__new(const void *data, __u32 size);
6729
LIBBPF_API struct btf *btf__parse(const char *path, struct btf_ext **btf_ext);

0 commit comments

Comments
 (0)