aboutsummaryrefslogtreecommitdiff
path: root/gcc/btfout.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/btfout.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/btfout.cc')
-rw-r--r--gcc/btfout.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/btfout.cc b/gcc/btfout.cc
index 31af505..594cba8 100644
--- a/gcc/btfout.cc
+++ b/gcc/btfout.cc
@@ -463,6 +463,7 @@ btf_dtd_emit_preprocess_cb (ctf_container_ref ctfc, ctf_dtdef_ref dtd)
ctf_dtdef_ref func_dtd = ggc_cleared_alloc<ctf_dtdef_t> ();
func_dtd->dtd_data = dtd->dtd_data;
func_dtd->dtd_data.ctti_type = dtd->dtd_type;
+ func_dtd->linkage = dtd->linkage;
vec_safe_push (funcs, func_dtd);
num_types_created++;
@@ -740,7 +741,10 @@ static void
btf_asm_func_type (ctf_dtdef_ref dtd)
{
dw2_asm_output_data (4, dtd->dtd_data.ctti_name, "btt_name");
- dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_FUNC, 0, 0), "btt_info");
+ dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_FUNC, 0,
+ dtd->linkage),
+ "btt_info: kind=%u, kflag=%u, linkage=%u",
+ BTF_KIND_FUNC, 0, dtd->linkage);
dw2_asm_output_data (4, get_btf_id (dtd->dtd_data.ctti_type), "btt_type");
}