]> git.ipfire.org Git - thirdparty/gcc.git/commit
btf: emit linkage information in BTF_KIND_FUNC entries
authorJose E. Marchesi <jose.marchesi@oracle.com>
Fri, 8 Jul 2022 16:32:02 +0000 (18:32 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Mon, 1 Aug 2022 17:44:12 +0000 (19:44 +0200)
commit32566720f3a9135fa355f0304f024a79f107a1b8
tree1f2f05a42c22bedf6b9f0e440dc79edb37b07b41
parentb64e937ccde286278743e8fdffea494faa46c214
btf: emit linkage information in BTF_KIND_FUNC entries

The kernel bpftool expects BTF_KIND_FUNC entries in BTF to include an
annotation reflecting the linkage of functions (static, global).  For
whatever reason they abuse the `vlen' field of the BTF_KIND_FUNC entry
instead of adding a variable-part to the record like it is done with
other entry kinds.

This patch makes GCC to include this linkage info in BTF_KIND_FUNC
entries.

Tested in bpf-unknown-none target.

gcc/ChangeLog:

PR debug/106263
* ctfc.h (struct ctf_dtdef): Add field linkage.
* ctfc.cc (ctf_add_function): Set ctti_linkage.
* dwarf2ctf.cc (gen_ctf_function_type): Pass a linkage for
function types and subprograms.
* btfout.cc (btf_asm_func_type): Emit linkage information for the
function.
(btf_dtd_emit_preprocess_cb): Propagate the linkage information
for functions.

gcc/testsuite/ChangeLog:

PR debug/106263
* gcc.dg/debug/btf/btf-function-4.c: New test.
* gcc.dg/debug/btf/btf-function-5.c: Likewise.
gcc/btfout.cc
gcc/ctfc.cc
gcc/ctfc.h
gcc/dwarf2ctf.cc
gcc/testsuite/gcc.dg/debug/btf/btf-function-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/debug/btf/btf-function-5.c [new file with mode: 0644]