if (TARGET_BPF_CORE && !btf_debuginfo_p ())
error ("BPF CO-RE requires BTF debugging information, use %<-gbtf%>");
- /* To support the portability needs of BPF CO-RE approach, BTF debug
- information includes the BPF CO-RE relocations. */
- if (TARGET_BPF_CORE)
- write_symbols |= BTF_WITH_CORE_DEBUG;
+ /* BPF applications always generate .BTF.ext. */
+ write_symbols |= BTF_WITH_CORE_DEBUG;
/* Unlike much of the other BTF debug information, the information necessary
for CO-RE relocations is added to the CTF container by the BPF backend.
/* -gbtf implies -mcore when using the BPF backend, unless -mno-co-re
is specified. */
if (btf_debuginfo_p () && !(target_flags_explicit & MASK_BPF_CORE))
- {
- target_flags |= MASK_BPF_CORE;
- write_symbols |= BTF_WITH_CORE_DEBUG;
- }
+ target_flags |= MASK_BPF_CORE;
/* Determine available features from ISA setting (-mcpu=). */
if (bpf_has_jmpext == -1)
static void
bpf_asm_init_sections (void)
{
- if (TARGET_BPF_CORE)
+ if (btf_debuginfo_p () && btf_with_core_debuginfo_p ())
btf_ext_init ();
}
static void
bpf_file_end (void)
{
- if (TARGET_BPF_CORE)
- btf_ext_output ();
+ if (btf_debuginfo_p () && btf_with_core_debuginfo_p ())
+ {
+ btf_ext_output ();
+ btf_finalize ();
+ }
}
#undef TARGET_ASM_FILE_END
if (btf)
{
btf_output (filename);
- btf_finalize ();
+ /* btf_finalize when compiling BPF applciations gets deallocated by the
+ BPF target in bpf_file_end. */
+ if (btf_debuginfo_p () && !btf_with_core_debuginfo_p ())
+ btf_finalize ();
}
else
/* Emit BTF debug info here when CO-RE relocations need to be generated.
BTF with CO-RE relocations needs to be generated when CO-RE is in effect
for the BPF target. */
- if (btf_with_core_debuginfo_p ())
- {
- gcc_assert (btf_debuginfo_p ());
- ctf_debug_finalize (filename, btf_debuginfo_p ());
- }
+ if (btf_debuginfo_p () && btf_with_core_debuginfo_p ())
+ ctf_debug_finalize (filename, btf_debuginfo_p ());
}
#include "gt-dwarf2ctf.h"