https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128479
Bug ID: 128479
Summary: btf_type_tag on a pointed-to function is rejected, and
the tag is lost from the debug info
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: wrong-debug
Severity: normal
Priority: P3
Component: debug
Assignee: vineetg at gcc dot gnu.org
Reporter: vineetg at gcc dot gnu.org
CC: dfaust at gcc dot gnu.org, jemarch at gcc dot gnu.org
Target Milestone: ---
A btf_type_tag that reaches a pointer through the function it points to is
rejected, and no annotation is emitted.
```c
#define __rcu __attribute__((btf_type_tag("rcu")))
struct rethook_node;
struct rethook { void (__rcu *handler)(struct rethook_node *, unsigned long);
};
struct rethook r;
```
$ gcc -g -c t.c
t.c:4:47: warning: 'btf_type_tag' attribute does not apply to functions
[-Wattributes]
There is no DW_TAG_GNU_annotation in the output, so BTF generated from the
DWARF holds
PTR -> FUNC_PROTO
clang accepts the same declaration without a diagnostic and records
PTR -> TYPE_TAG 'rcu' -> FUNC_PROTO
The function here is a pointee, and the tag belongs on it as on any other
pointed-to type.
A related scenario is a pointer formed from an object that is already tagged:
#define __tag __attribute__((btf_type_tag("t")))
extern __tag int obj;
__typeof__(&obj) p;
GCC records that annotation on the pointed-to base type DIE. pahole does
not translate an annotation in that position, so the tag does not reach
BTF at all:
gcc PTR -> INT (tag lost)
clang PTR -> TYPE_TAG 't' -> INT