[PATCH] D68822: [WIP][BPF] Support external globals
Yonghong Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 11:50:39 PDT 2019
yonghong-song created this revision.
yonghong-song added reviewers: ast, anakryiko.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Emit types for all globals. Previously, the types for external
variables and globals with section names are omitted.
For external variables, also provide additional information
about the purpose of the extern's through section name.
For example, for the following example,
-bash-4.4$ cat t.c
extern int a __attribute__((section("bpf_linux")));
extern int b __attribute__((section("bpf_curr_module")));
extern int c __attribute__((section("bpf_cross_module")));
int test() {
return a + b + c;
}
-bash-4.4$ clang -target bpf -g -O2 -S t.c
Generated BTF_KIND_VARs:
.long 66 # BTF_KIND_VAR(id = 4)
.long 234881024 # 0xe000000
.long 0
.long 18
<=== 1 << 4 | 2 extern linux symbols
.long 68 # BTF_KIND_VAR(id = 5)
.long 234881024 # 0xe000000
.long 0
.long 34
<=== 2 << 4 | 2 current module to-be-patched symbols
.long 70 # BTF_KIND_VAR(id = 6)
.long 234881024 # 0xe000000
.long 0
.long 2
<=== 0 << 4 | 2 extern cross bpf module symbols
The current u32 is defined as below in uapi/linux/btf.h:
enum {
BTF_VAR_STATIC = 0,
BTF_VAR_GLOBAL_ALLOCATED,
};
struct btf_var {
__u32 linkage;
};
We may need to add macros to access linkage and other information.
We need to carve bits with some reserved.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D68822
Files:
llvm/lib/Target/BPF/BTF.h
llvm/lib/Target/BPF/BTFDebug.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68822.224429.patch
Type: text/x-patch
Size: 5862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/2e954336/attachment.bin>
More information about the llvm-commits
mailing list