[PATCH] D73902: [BPF] handle typedef of struct/union for CO-RE relocations
Yonghong Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 3 08:59:24 PST 2020
yonghong-song created this revision.
yonghong-song added reviewers: ast, anakryiko.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Linux commit
https://github.com/torvalds/linux/commit/1cf5b23988ea0086a252a5c8b005b075f1e9b030#diff-289313b9fec99c6f0acfea19d9cfd949
uses "#pragma clang attribute push (__attribute__((preserve_access_index)),
apply_to = record)"
to apply CO-RE relocations to all records including the following pattern:
#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)
typedef struct {
int a;
} __t;
#pragma clang attribute pop
int test(__t *arg) { return arg->a; }
The current approach to use struct/union type in the relocation record will
result in an anonymous struct, which make later type matching difficult
in bpf loader. In fact, current BPF backend will fail the above program
with assertion:
clang: ../lib/Target/BPF/BPFAbstractMemberAccess.cpp:796: ...
Assertion `TypeName.size()' failed.
clang will change to use the type of the base of the member access
which will preserve the typedef modifier for the
preserve_{struct,union}_access_index intrinsics in the above example.
Here we adjust BPF backend to accept that the debuginfo
type metadata may be 'typedef' and handle them properly.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73902
Files:
llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
llvm/test/CodeGen/BPF/CORE/offset-reloc-typedef-struct-2.ll
llvm/test/CodeGen/BPF/CORE/offset-reloc-typedef-union-2.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73902.242099.patch
Type: text/x-patch
Size: 12048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200203/d7ddbfdb/attachment.bin>
More information about the llvm-commits
mailing list