aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2ctf.cc
diff options
context:
space:
mode:
authorJose E. Marchesi <jose.marchesi@oracle.com>2022-07-08 18:32:02 +0200
committerJose E. Marchesi <jose.marchesi@oracle.com>2022-08-01 19:44:12 +0200
commit32566720f3a9135fa355f0304f024a79f107a1b8 (patch)
tree1f2f05a42c22bedf6b9f0e440dc79edb37b07b41 /gcc/dwarf2ctf.cc
parentb64e937ccde286278743e8fdffea494faa46c214 (diff)
downloadgcc-32566720f3a9135fa355f0304f024a79f107a1b8.zip
gcc-32566720f3a9135fa355f0304f024a79f107a1b8.tar.gz
gcc-32566720f3a9135fa355f0304f024a79f107a1b8.tar.bz2
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.
Diffstat (limited to 'gcc/dwarf2ctf.cc')
-rw-r--r--gcc/dwarf2ctf.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/dwarf2ctf.cc b/gcc/dwarf2ctf.cc
index a6329ab..3971000 100644
--- a/gcc/dwarf2ctf.cc
+++ b/gcc/dwarf2ctf.cc
@@ -644,6 +644,7 @@ gen_ctf_function_type (ctf_container_ref ctfc, dw_die_ref function,
ctf_funcinfo_t func_info;
uint32_t num_args = 0;
+ int linkage = get_AT_flag (function, DW_AT_external);
ctf_id_t return_type_id;
ctf_id_t function_type_id;
@@ -687,7 +688,8 @@ gen_ctf_function_type (ctf_container_ref ctfc, dw_die_ref function,
function_name,
(const ctf_funcinfo_t *)&func_info,
function,
- from_global_func);
+ from_global_func,
+ linkage);
/* Second pass on formals: generate the CTF types corresponding to
them and add them as CTF function args. */