Repository navigation
Add a generator of vmlinux.h for C++ - #7
Merged
Merged
Conversation
The vmlinux.h from bpftool has about 160 C++ errors: keywords as names, typedef _Bool bool, tags that clash with typedefs, enum declarations without a type, anonymous members of named struct types, and empty structs, which have size 1 in C++ and shift the members after them. scripts/gen-vmlinux.py changes the names and types in BTF where C++ needs it and lets bpftool dump the result, so the layout stays bpftool's. Renamed types get a ___cpp suffix, which libbpf ignores in CO-RE. scripts/check-vmlinux.sh compiles the header as C and C++ with static asserts on the size and member offsets of each type from BTF, and checks that C++ fails none that C passes. CI runs it on the runner's kernel. Signed-off-by: Maxim Skokov <[email protected]>
mk/cppbpf.mk builds $(OUT)/include/vmlinux.h from VMLINUX_BTF, by default the running kernel's; an empty VMLINUX_BTF builds without it. The tests and syscount use it instead of hand-written kernel types, and the basic test checks a CO-RE relocation against a renamed type, struct class___cpp. Signed-off-by: Maxim Skokov <[email protected]>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bpftool's vmlinux.h has 100-160 C++ errors depending on the kernel. scripts/gen-vmlinux.py changes the names and types in BTF where C++ needs it and lets bpftool dump the result; scripts/check-vmlinux.sh checks in CI that C++ sees the same type layout as C. mk/cppbpf.mk builds the header as $(OUT)/include/vmlinux.h, and the tests and syscount use it instead of hand-written kernel types. Closes #2.
AIL:2