llvm commit ([1]) added support for btf_decl_tag attribute
with typedef declaration. Eventually, DW_TAG_LLVM_annotation
tag may appear inside dwarf typedef declaration tag.
kernel support for typedef BTF_KIND_DECL_TAG support
is introduced in [2]. There is no additional libbpf
change needed as the previous libbpf BTF_KIND_DECL_TAG
support is generic enough to cover new typedef use
cases.
This patch added parsing of DW_TAG_LLVM_annotation
for dwarf typedef decl.
$ cat t.c
$ clang -O2 -g -c t.c
$ llvm-dwarfdump --debug-info t.o
......
0x00000033: DW_TAG_typedef
DW_AT_type (0x00000051 "structure ")
DW_AT_name ("__t")
DW_AT_decl_file ("/home/yhs/t.c")
DW_AT_decl_line (3)
0x0000003e: DW_TAG_LLVM_annotation
DW_AT_name ("btf_decl_tag")
DW_AT_const_value ("tag1")
0x00000047: DW_TAG_LLVM_annotation
DW_AT_name ("btf_decl_tag")
DW_AT_const_value ("tag2")
0x00000050: NULL
Previously, pahole will issue a warning if typedef tag
contains any child tag. I removed this warning since
it is not true any more. Note that dwarf standard doesn't
prevent typedef decl tag from having nested tags.
In the future if we need to process any tag inside
typedef tag, we can just add code to process it.
[1] https://reviews.llvm.org/D110127
[2] https://lore.kernel.org/bpf/20211021195628.4018847-1-yhs@fb.com
Signed-off-by: Yonghong Song <yhs@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Build instructions:
1. install cmake
2. mkdir build
3. cd build
4. cmake -D__LIB=lib ..
5. make install
cmake Options:
-DBUILD_SHARED_LIBS
By default SHARED libraries are created and applications are linked to it.
Use -DBUILD_SHARED_LIBS=OFF while invoking cmake to create STATIC libraries
and link applications to it.
Ex. cmake -D__LIB=lib -DBUILD_SHARED_LIBS=OFF ..
-DCMAKE_INSTALL_PREFIX
Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
when invoking cmake to specify another install location.
Known to work scenarios:
Mandriva Cooker:
cmake 2.4.5-1mdv2007.1
libelfutils1-devel 0.123-1mdv2007.1
Debian Unstable:
cmake 2.4.5-1
libdw-dev 0.123-2
Fedora Core 6:
cmake 2.4.5-2.fc6
elfutils-devel 0.126-1.fc6