You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[BPF] Generate BTF info using 'btf:type_tag' annotation
This is a follow-up for BPF mailing list discussion at [1].
Previous commit in a series updated DWARF generation for the following
example:
int __attribute__((btf_type_tag("tag1"))) *g;
To generate DWARF that looks as follows:
0x0000001e: DW_TAG_variable
DW_AT_name ("g")
DW_AT_type (0x00000029 "int *")
0x00000029: DW_TAG_pointer_type
DW_AT_type (0x00000032 "int")
0x00000032: DW_TAG_base_type
DW_AT_name ("int")
0x00000036: DW_TAG_LLVM_annotation
DW_AT_name ("btf:type_tag")
DW_AT_const_value ("tag1")
The fresh part is attachment of `btf:type_tag` annotations to types
other than pointers. This commit changes BTF generation to rely on
`btf:type_tag` annotations to generate TYPE_TAG entries.
This necessitates the following changes:
- The logic for `BTFTypeTypeTag` chains creation is moved to
`BTFDebug::addType()`;
- Special logic is added to avoid duplicate BTF entries for tagged
and un-tagged type variants, e.g. in the following case:
#define __tag1 __attribute__((btf_type_tag("tag1")))
#define __tag2 __attribute__((btf_type_tag("tag2")))
struct foo {};
struct bar {
struct foo __tag1 aa;
struct foo __tag2 bb;
struct foo cc;
};
Debug information generated for this example contains three
instances of `DICompositeType(name: "foo")` with different
`annotations` fields, however single BTF definition for structure
"foo" should be generated. Field `BTFDebug::DIDedupMap` and method
`BTFDebug::lookupType()` are responsible for this logic;
- Care is taken to avoid references to type tags in relocation
entries.
[1] https://lore.kernel.org/bpf/87r0w9jjoq.fsf@oracle.com/
This was previously tracked as differential revision:
https://reviews.llvm.org/D145891
0 commit comments