-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit makes the DeclTag BTF type exported. The DeclTag has been unexported because its encoding is a bit tricky. DeclTags on the wire refer to a type by its ID, and an component index. Unlike other BTF types, the type ID isn't always the actual "target", instead if the component index is not `-1` it targets a child object of the type. This commit adds a `Tags` field to all types that can have DeclTags including Members. Exception is function parameters. Due to the func -> funcProto -> parameter encoding, it is possible that BTF deduplication reuses the same funcProto for multiple functions. The declTags point to the func to annotate the arguments. Thus, adding a `Tags` field to Param would cause inaccurate BTF marshalling. Instead, a `ParamTags` field is added the func as `[][]string` to match the write format more closely to avoid issues caused by BTF deduplication. This is a compromise between technical feasibility and user experience. Users need to manually match up the `ParamTags` with the `Params`. This shouldn't be a huge issue in most cases however. This means we now effectively have less "types" in our Go BTF representation then we have on the wire since declTags become strings on other types. This might leave "holes" in our BTF type numbering if we were to remove them. So instead we leave the `declTag` types in the BTF type list, but we hide them from the user during iteration. Technically, users can still access them by ID if they know the ID, but like before this commit, the returned value can only be printed. Marshalling relies on the iteration of the BTF types. When go to load a BTF blob from a collection, we iterate from a collection of root types which are directly used. This causes us to load only BTF info that is actually in use. This commit introduces a trick into the `children` logic used during iteration. When we iterate over a type with declTags, we create internal `declTag` types at-hoc with the correct component index. So even though the tags are just strings on other types, when iterating they appear as actual types. This causes only declTags that are on types which are in use to be marshalled. Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
- Loading branch information
1 parent
13e5cfb
commit 2c0d9a6
Showing
11 changed files
with
224 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "../../testdata/common.h" | ||
|
||
#define tagA __attribute__((btf_decl_tag("a"))) | ||
#define tagB __attribute__((btf_decl_tag("b"))) | ||
#define tagC __attribute__((btf_decl_tag("c"))) | ||
#define tagD __attribute__((btf_decl_tag("d"))) | ||
#define tagE __attribute__((btf_decl_tag("e"))) | ||
|
||
struct s { | ||
char tagA foo; | ||
char tagB bar; | ||
} tagC; | ||
|
||
union u { | ||
char tagA foo; | ||
char tagB bar; | ||
} tagC; | ||
|
||
typedef tagB char td; | ||
|
||
struct s tagD s1; | ||
union u tagE u1; | ||
td tagA t1; | ||
|
||
int tagA tagB fwdDecl(char tagC x, char tagD y); | ||
|
||
int tagE normalDecl1(char tagB x, char tagC y) { | ||
return fwdDecl(x, y); | ||
} | ||
|
||
int tagE normalDecl2(char tagB x, char tagC y) { | ||
return fwdDecl(x, y); | ||
} | ||
|
||
__section("syscall") int prog(char *ctx) { | ||
return normalDecl1(ctx[0], ctx[1]) + normalDecl2(ctx[2], ctx[3]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.