]> git.ipfire.org Git - thirdparty/gcc.git/commit
bpf: implementation of func_info in .BTF.ext.
authorCupertino Miranda <cupertino.miranda@oracle.com>
Mon, 12 Feb 2024 17:46:03 +0000 (17:46 +0000)
committerCupertino Miranda <cupertino.miranda@oracle.com>
Wed, 28 Feb 2024 19:20:21 +0000 (19:20 +0000)
commit77142bdba485057550c5d849864948b0d20be8af
tree6122a8242d4c336f8a354e59a2d55407ba27acfe
parent38d2eb337b41e9cdc5eb89ab865d74ef5304bc03
bpf: implementation of func_info in .BTF.ext.

Kernel verifier complains in some particular cases for missing func_info
implementation in .BTF.ext. This patch implements it.

Strings are cached locally in coreout.cc to avoid adding duplicated
strings in the string list. This string deduplication should eventually
be moved to the CTFC functions such that this happens widely.

With this implementation, the CO-RE relocations information was also
simplified and integrated with the FuncInfo structures.

gcc/Changelog:

PR target/113453
* config/bpf/bpf.cc (bpf_function_prologue): Define target
hook.
* config/bpf/coreout.cc (brf_ext_info_section)
(btf_ext_info): Move from coreout.h
(btf_ext_funcinfo, btf_ext_lineinfo): Add struct.
(bpf_core_reloc): Rename to btf_ext_core_reloc.
(btf_ext): Add static variable.
(btfext_info_sec_find_or_add, SEARCH_NODE_AND_RETURN)
(bpf_create_or_find_funcinfo, bpt_create_core_reloc)
(btf_ext_add_string, btf_funcinfo_type_callback)
(btf_add_func_info_for, btf_validate_funcinfo)
(btf_ext_info_len, output_btfext_func_info): Add function.
(output_btfext_header, bpf_core_reloc_add)
(output_btfext_core_relocs, btf_ext_init, btf_ext_output):
Change to support new structs.
* config/bpf/coreout.h (btf_ext_funcinfo, btf_ext_lineinfo):
Move and change in coreout.cc.
(btf_add_func_info_for, btf_ext_add_string): Add prototypes.

gcc/testsuite/ChangeLog:
PR target/113453
* gcc.target/bpf/btfext-funcinfo-nocore.c: Add.
* gcc.target/bpf/btfext-funcinfo.c: Add.
* gcc.target/bpf/core-attr-5.c: Fix regexp.
* gcc.target/bpf/core-attr-6.c: Fix regexp.
* gcc.target/bpf/core-builtin-fieldinfo-offset-1.c: Fix regexp.
* gcc.target/bpf/core-section-1.c: Fix regexp.
gcc/config/bpf/bpf.cc
gcc/config/bpf/coreout.cc
gcc/config/bpf/coreout.h
gcc/testsuite/gcc.target/bpf/btfext-funcinfo-nocore.c [new file with mode: 0644]
gcc/testsuite/gcc.target/bpf/btfext-funcinfo.c [new file with mode: 0644]
gcc/testsuite/gcc.target/bpf/core-attr-5.c
gcc/testsuite/gcc.target/bpf/core-attr-6.c
gcc/testsuite/gcc.target/bpf/core-builtin-fieldinfo-offset-1.c
gcc/testsuite/gcc.target/bpf/core-section-1.c