[PATCH] D133361: [BPF] Attribute btf_decl_tag("ctx") for structs
Alexei Starovoitov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 30 10:33:17 PDT 2023
ast added a comment.
> I can rename these things, but tbh I don't think this functionality would be useful anywhere outside BPF, thus such renaming would be kind-of deceptive (and in case it would be useful, the renaming could be done at the time of second use).
I agree that it's not useful outside of BPF, but it's useful outside of 'ctx'. I think 'preserve_constant_field_offset' would be more accurate description of the restriction.
We can expand in the doc that it's a constant offset when field of the struct is accessed.
Also instead of btf_tag it would be better to add another builtin similar to preserve_access_index.
Currently we add __attribute__((preserve_access_index)) to trigger CO-RE.
This one will be a new __attribute__((preserve_constant_field_offset)) that will be specified manually either in uapi/bpf.h or in vmlinux.h on some structs
and it will have precedence over preserve_access_index, so
(__attribute__((preserve_access_index)), apply_to = record) in vmlinux.h will be ignored on such structs.
Otherwise it's a bit odd that special names inside btf_tag have stronger rules than other __attribute__((preserve_access_index)).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133361/new/
https://reviews.llvm.org/D133361
More information about the cfe-commits
mailing list