You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make change in BTFDebug.cpp to handle DW_TAG_atomic_type properly.
Otherwise, a type like
_Atomic int i; // global
the dwarf type chain atomic->int
Since DW_TAG_atomic_type is not processed BTF generation will stop
at atomic modifier and BTF will encode 'i' as void type.
Similar for type like
volatile _Atomic int *p;
the dwarf type chain ptr->volatile->atomic->int
Since atomic type is not processed and BTF generation will stop at
atomic type, the eventual BTF type will be
ptr->volatile->void
which is incorrect.
This patch fixed the following cases including the above two patterns
by skipping DW_TAG_atomic_type:
- global variable with _Atomic type.
- function parameter and return type with _Atomic type.
- struct member with _Atomic type.
- ptr,const,volatile,restrict pointing to a _Atomic type.
- btf_type_tag where ptr pointing to _Atomic type and btf_type_tag.
With changed llvm, in kernel selftest arena_atomics.c ([1]), the new bpf
code looks like
```
_Atomic __u64 __arena_global and64_value = (0x110ull << 32);
_Atomic __u32 __arena_global and32_value = 0x110;
SEC("raw_tp/sys_enter")
int and(const void *ctx)
{
...
__c11_atomic_fetch_and(&and64_value, 0x011ull << 32, memory_order_relaxed);
__c11_atomic_fetch_and(&and32_value, 0x011, memory_order_relaxed);
...
return 0;
}
```
and compilation is successful.
The skel file arena_atomics.skel.h will be
```
struct arena_atomics__arena {
...
__u64 and64_value;
__u32 and32_value;
...
} *arena;
```
[1] https://lore.kernel.org/r/[email protected]
0 commit comments