Skip to content
Snippets Groups Projects
  • David Faust's avatar
    189d0f1f
    bpf,btf: enable BTF pruning by default for BPF · 189d0f1f
    David Faust authored
    
    This patch enables -gprune-btf by default in the BPF backend when
    generating BTF information, and fixes BPF CO-RE generation when using
    -gprune-btf.
    
    When generating BPF CO-RE information, we must ensure that types used
    in CO-RE relocations always have sufficient BTF information emited so
    that the CO-RE relocations can be processed by a BPF loader.  The BTF
    pruning algorithm on its own does not have sufficient information to
    determine which types are used in a BPF CO-RE relocation, so this
    information must be supplied by the BPF backend, using a new
    btf_mark_type_used function.
    
    Co-authored-by: default avatarCupertino Miranda <cupertino.miranda@oracle.com>
    
    gcc/
    	* btfout.cc (btf_mark_type_used): New.
    	* ctfc.h (btf_mark_type_used): Declare it here.
    	* config/bpf/bpf.cc (bpf_option_override): Enable -gprune-btf
    	by default if -gbtf is enabled.
    	* config/bpf/core-builtins.cc (extra_fn): New typedef.
    	(compute_field_expr): Add callback parameter, and call it if supplied.
    	Fix computation for MEM_REF.
    	(mark_component_type_as_used): New.
    	(bpf_mark_types_as_used): Likewise.
    	(bpf_expand_core_builtin): Call here.
    	* doc/invoke.texi (Debugging Options): Note that -gprune-btf is
    	enabled by default for BPF target when generating BTF.
    
    gcc/testsuite/
    	* gcc.dg/debug/btf/btf-variables-5.c: Adjust one test for bpf-*-*
    	target.
    189d0f1f
    History
    bpf,btf: enable BTF pruning by default for BPF
    David Faust authored
    
    This patch enables -gprune-btf by default in the BPF backend when
    generating BTF information, and fixes BPF CO-RE generation when using
    -gprune-btf.
    
    When generating BPF CO-RE information, we must ensure that types used
    in CO-RE relocations always have sufficient BTF information emited so
    that the CO-RE relocations can be processed by a BPF loader.  The BTF
    pruning algorithm on its own does not have sufficient information to
    determine which types are used in a BPF CO-RE relocation, so this
    information must be supplied by the BPF backend, using a new
    btf_mark_type_used function.
    
    Co-authored-by: default avatarCupertino Miranda <cupertino.miranda@oracle.com>
    
    gcc/
    	* btfout.cc (btf_mark_type_used): New.
    	* ctfc.h (btf_mark_type_used): Declare it here.
    	* config/bpf/bpf.cc (bpf_option_override): Enable -gprune-btf
    	by default if -gbtf is enabled.
    	* config/bpf/core-builtins.cc (extra_fn): New typedef.
    	(compute_field_expr): Add callback parameter, and call it if supplied.
    	Fix computation for MEM_REF.
    	(mark_component_type_as_used): New.
    	(bpf_mark_types_as_used): Likewise.
    	(bpf_expand_core_builtin): Call here.
    	* doc/invoke.texi (Debugging Options): Note that -gprune-btf is
    	enabled by default for BPF target when generating BTF.
    
    gcc/testsuite/
    	* gcc.dg/debug/btf/btf-variables-5.c: Adjust one test for bpf-*-*
    	target.