public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH,V3 0/3] Allow means for late BTF generation for BPF CO-RE
@ 2021-08-31 14:08 Indu Bhagat
  2021-08-31 14:08 ` [PATCH,V3 1/3] debug: add BTF_WITH_CORE_DEBUG debug format Indu Bhagat
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Indu Bhagat @ 2021-08-31 14:08 UTC (permalink / raw)
  To: gcc-patches

[Changes from V2]
- Instead of target hook, the patch set now adds a new debug format
BTF_WITH_CORE_DEBUG.
- Renamed the BPF option from -mcore to -mco-re.
- Adapted the commit logs a bit.
[End of Changes from V2]


Hello,

This patch series puts the framework in place for late BTF generation (in
dwarf2out_finish). This is needed for the landing of BPF CO-RE support in GCC,
patches for which were posted earlier -
https://gcc.gnu.org/pipermail/gcc-patches/2021-August/576719.html.

BPF's Compile Once - Run Everywhere (CO-RE) feature is used to make a compiled 
BPF program portable across kernel versions, all this without the need to
recompile the BPF program. A key part of BPF CO-RE capability is the BTF debug
info generated for them.

A traditional BPF program (non CO-RE) will have a .BTF section which contains
the type information in the BTF debug format.  In case of CO-RE, however, an 
additional section .BTF.ext section is used.  The .BTF.ext section contains
the CO-RE relocations. A BPF loader will use the .BTF.ext section along with the
associated .BTF section to adjust some references in the instructions of BPF
program to ensure it is compatible with the required kernel version / headers.

A .BTF.ext section contains the CO-RE relocation records. Roughly, each CO-RE
relocation record will contain the following info:
 - offset of BPF instruction to be patched
 - the BTF ID of the data structure being accessed by the instruction, and 
 - an offset to the "access string" - a BTF string which encodes a series of 
   field accesses to retrieve the field of interest in the instruction.

The .BTF.ext section does not have a string table of its own, so these "access
strings" are placed in the .BTF section string table. The CO-RE relocation
records refer to them by offset into the .BTF string table.

Example of access string encoding:

 struct S {
     int a;
     union {
	 int _unused;
	 int b;
	 char c;
	 } u[4];
 };

struct S *foo = ...;
int x  = foo->a;          /* encoded as "0:0"     */
int y  = foo[4]->u[2].b   /* encoded as "4:1:2:1" */
char z = foo->u[3].c      /* encoded as "0:1:3:2" */

This means that writing out of a .BTF section needs to be delayed until after
these "access strings" have been added by the BPF backend, when CO-RE is in
effect.

High-level design
-----------------
- The CTF container (CTFC) is populated with the compiler-internal
representation for the "type information" at dwarf2out_early_finish time.  This
information is used for generation of the .BTF section.
- For CO-RE relocation records, the information needed to generate .BTF.ext
section is added by the BPF backend to the CTF container (CTFC) at expand time.
- A new debug format BTF_WITH_CORE_DEBUG is being added.
- The BPF backend updates the write_symbols variable with BTF_WITH_CORE_DEBUG
debug format signalling the rest of the compiler that BPF/CO-RE is in effect,
and hence the need to generate the BTF CO-RE relocation records.
- BTF debug information is emitted late in dwarf2out_finish when
BTF_WITH_CORE_DEBUG debug format is requested by the user (implicitly via the
command line option -mco-re for the BPF backend).
- Combining early BTF and late BTF/CO-RE debug information is not feasible due
to the way BTF CO-RE format is defined and lack of linker support for the BTF
debug format.
- Lastly, LTO is disallowed to be used together with CO-RE for the BPF target.

Testing Notes
------------
- Bootstrapped and reg tested on x86_64
- make all-gcc for --target=bpf-unknown-none; tested ctf.exp, btf.exp and bpf.exp

Thanks,

Indu Bhagat (3):
  debug: add BTF_WITH_CORE_DEBUG debug format
  bpf: Add new -mco-re option for BPF CO-RE
  dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase

 gcc/config/bpf/bpf.c                      | 25 ++++++++++++++
 gcc/config/bpf/bpf.opt                    |  4 +++
 gcc/dwarf2ctf.c                           | 54 +++++++++++++++++++++++--------
 gcc/dwarf2ctf.h                           |  4 ++-
 gcc/dwarf2out.c                           |  9 ++++--
 gcc/flag-types.h                          |  6 +++-
 gcc/flags.h                               |  4 +++
 gcc/opts.c                                |  8 +++++
 gcc/testsuite/gcc.target/bpf/core-lto-1.c |  9 ++++++
 9 files changed, 106 insertions(+), 17 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/bpf/core-lto-1.c

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH,V3 1/3] debug: add BTF_WITH_CORE_DEBUG debug format
  2021-08-31 14:08 [PATCH,V3 0/3] Allow means for late BTF generation for BPF CO-RE Indu Bhagat
@ 2021-08-31 14:08 ` Indu Bhagat
  2021-08-31 14:08 ` [PATCH,V3 2/3] bpf: Add new -mco-re option for BPF CO-RE Indu Bhagat
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Indu Bhagat @ 2021-08-31 14:08 UTC (permalink / raw)
  To: gcc-patches

To best handle BTF/CO-RE in GCC, a distinct BTF_WITH_CORE_DEBUG debug format is
being added.  This helps the compiler detect whether BTF with CO-RE relocations
needs to be emitted.

gcc/ChangeLog:

	* flag-types.h (enum debug_info_type): Add new enum
	DINFO_TYPE_BTF_WITH_CORE.
	(BTF_WITH_CORE_DEBUG): New bitmask.
	* flags.h (btf_with_core_debuginfo_p): New declaration.
	* opts.c (btf_with_core_debuginfo_p): New definition.
---
 gcc/flag-types.h | 6 +++++-
 gcc/flags.h      | 4 ++++
 gcc/opts.c       | 8 ++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gcc/flag-types.h b/gcc/flag-types.h
index 4fb1cb4..cc41b2a 100644
--- a/gcc/flag-types.h
+++ b/gcc/flag-types.h
@@ -31,7 +31,8 @@ enum debug_info_type
   DINFO_TYPE_VMS = 4,		  /* VMS debug info.  */
   DINFO_TYPE_CTF = 5,		  /* CTF debug info.  */
   DINFO_TYPE_BTF = 6,		  /* BTF debug info.  */
-  DINFO_TYPE_MAX = DINFO_TYPE_BTF /* Marker only.  */
+  DINFO_TYPE_BTF_WITH_CORE = 7,	  /* BTF debug info with CO-RE relocations.  */
+  DINFO_TYPE_MAX = DINFO_TYPE_BTF_WITH_CORE /* Marker only.  */
 };
 
 #define NO_DEBUG      (0U)
@@ -47,6 +48,9 @@ enum debug_info_type
 #define CTF_DEBUG     (1U << DINFO_TYPE_CTF)
 /* Write BTF debug info (using btfout.c).  */
 #define BTF_DEBUG     (1U << DINFO_TYPE_BTF)
+/* Write BTF debug info for BPF CO-RE usecase (using btfout.c).  */
+#define BTF_WITH_CORE_DEBUG     (1U << DINFO_TYPE_BTF_WITH_CORE)
+
 /* Note: Adding new definitions to handle -combination- of debug formats,
    like VMS_AND_DWARF2_DEBUG is not recommended.  This definition remains
    here for historical reasons.  */
diff --git a/gcc/flags.h b/gcc/flags.h
index afedef0..af61bcd 100644
--- a/gcc/flags.h
+++ b/gcc/flags.h
@@ -44,6 +44,10 @@ const char * debug_set_names (uint32_t w_symbols);
 
 extern bool btf_debuginfo_p ();
 
+/* Return true iff BTF with CO-RE debug info is enabled.  */
+
+extern bool btf_with_core_debuginfo_p ();
+
 /* Return true iff CTF debug info is enabled.  */
 
 extern bool ctf_debuginfo_p ();
diff --git a/gcc/opts.c b/gcc/opts.c
index e050155..1d2d22d 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -135,6 +135,14 @@ btf_debuginfo_p ()
   return (write_symbols & BTF_DEBUG);
 }
 
+/* Return TRUE iff BTF with CO-RE debug info is enabled.  */
+
+bool
+btf_with_core_debuginfo_p ()
+{
+  return (write_symbols & BTF_WITH_CORE_DEBUG);
+}
+
 /* Return TRUE iff CTF debug info is enabled.  */
 
 bool
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH,V3 2/3] bpf: Add new -mco-re option for BPF CO-RE
  2021-08-31 14:08 [PATCH,V3 0/3] Allow means for late BTF generation for BPF CO-RE Indu Bhagat
  2021-08-31 14:08 ` [PATCH,V3 1/3] debug: add BTF_WITH_CORE_DEBUG debug format Indu Bhagat
@ 2021-08-31 14:08 ` Indu Bhagat
  2021-08-31 14:08 ` [PATCH, V3 3/3] dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase Indu Bhagat
  2021-09-06  9:51 ` [PATCH,V3 0/3] Allow means for late BTF generation for BPF CO-RE Richard Biener
  3 siblings, 0 replies; 5+ messages in thread
From: Indu Bhagat @ 2021-08-31 14:08 UTC (permalink / raw)
  To: gcc-patches

-mco-re in the BPF backend enables code generation for the CO-RE usecase. LTO is
disabled for CO-RE compilations.

gcc/ChangeLog:

	* config/bpf/bpf.c (bpf_option_override): For BPF backend, disable LTO
	support when compiling for CO-RE.
	* config/bpf/bpf.opt: Add new command line option -mco-re.

gcc/testsuite/ChangeLog:

	* gcc.target/bpf/core-lto-1.c: New test.
---
 gcc/config/bpf/bpf.c                      | 25 +++++++++++++++++++++++++
 gcc/config/bpf/bpf.opt                    |  4 ++++
 gcc/testsuite/gcc.target/bpf/core-lto-1.c |  9 +++++++++
 3 files changed, 38 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/bpf/core-lto-1.c

diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c
index e635f9e..7228978 100644
--- a/gcc/config/bpf/bpf.c
+++ b/gcc/config/bpf/bpf.c
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "builtins.h"
 #include "predict.h"
 #include "langhooks.h"
+#include "flags.h"
 
 /* Per-function machine data.  */
 struct GTY(()) machine_function
@@ -158,6 +159,30 @@ bpf_option_override (void)
 {
   /* Set the initializer for the per-function status structure.  */
   init_machine_status = bpf_init_machine_status;
+
+  /* BPF CO-RE support requires BTF debug info generation.  */
+  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;
+
+  /* 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.
+     Enabling LTO adds some complications in the generation of the BPF CO-RE
+     relocations because if LTO is in effect, the relocations need to be
+     generated late in the LTO link phase.  This poses a new challenge for the
+     compiler to now provide means to combine the early BTF and late BTF CO-RE
+     debug info, similar to DWARF debug info.  BTF/CO-RE debug info is not
+     amenable to such a split generation and a later merging.
+
+     In any case, in absence of linker support for BTF sections at this time,
+     it is acceptable to simply disallow LTO for BPF CO-RE compilations.  */
+
+  if (flag_lto && TARGET_BPF_CORE)
+    sorry ("BPF CO-RE does not support LTO");
 }
 
 #undef TARGET_OPTION_OVERRIDE
diff --git a/gcc/config/bpf/bpf.opt b/gcc/config/bpf/bpf.opt
index 916b53c..4493067 100644
--- a/gcc/config/bpf/bpf.opt
+++ b/gcc/config/bpf/bpf.opt
@@ -127,3 +127,7 @@ Generate little-endian eBPF.
 mframe-limit=
 Target Joined RejectNegative UInteger IntegerRange(0, 32767) Var(bpf_frame_limit) Init(512)
 Set a hard limit for the size of each stack frame, in bytes.
+
+mco-re
+Target Mask(BPF_CORE)
+Generate all necessary information for BPF Compile Once - Run Everywhere.
diff --git a/gcc/testsuite/gcc.target/bpf/core-lto-1.c b/gcc/testsuite/gcc.target/bpf/core-lto-1.c
new file mode 100644
index 0000000..927de23
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/core-lto-1.c
@@ -0,0 +1,9 @@
+/* Test -mco-re with -flto.
+  
+   -mco-re is used to generate information for BPF CO-RE usecase. To support
+   the generataion of the .BTF and .BTF.ext sections in GCC, -flto is disabled
+   with -mco-re.  */
+
+/* { dg-do compile } */
+/* { dg-message "sorry, unimplemented: BPF CO-RE does not support LTO" "" { target bpf-*-* } 0 } */
+/* { dg-options "-gbtf -mco-re -flto" } */
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH, V3 3/3] dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase
  2021-08-31 14:08 [PATCH,V3 0/3] Allow means for late BTF generation for BPF CO-RE Indu Bhagat
  2021-08-31 14:08 ` [PATCH,V3 1/3] debug: add BTF_WITH_CORE_DEBUG debug format Indu Bhagat
  2021-08-31 14:08 ` [PATCH,V3 2/3] bpf: Add new -mco-re option for BPF CO-RE Indu Bhagat
@ 2021-08-31 14:08 ` Indu Bhagat
  2021-09-06  9:51 ` [PATCH,V3 0/3] Allow means for late BTF generation for BPF CO-RE Richard Biener
  3 siblings, 0 replies; 5+ messages in thread
From: Indu Bhagat @ 2021-08-31 14:08 UTC (permalink / raw)
  To: gcc-patches

DWARF generation is split between early and late phases when LTO is in effect.
This poses challenges for CTF/BTF generation especially if late debug info
generation is desirable, as turns out to be the case for BPF CO-RE.

The approach taken here in this patch is:

1. LTO is disabled for BPF CO-RE
The reason to disable LTO for BPF CO-RE is that if LTO is in effect, BPF CO-RE
relocations need to be generated in the LTO link phase _after_ the optimizations
are done. This means we need to devise way to combine early and late BTF. At
this time, in absence of linker support for BTF sections, it makes sense to
steer clear of LTO for BPF CO-RE and bypass the issue.

2. The BPF backend updates the write_symbols with BPF_WITH_CORE_DEBUG to convey
the case that BTF with CO-RE support needs to be generated.  This information
is used by the debug info emission routines to defer the emission of BTF/CO-RE
until dwarf2out_finish.

So, in other words,

dwarf2out_early_finish
  - Always emit CTF here.
  - if (BTF && !BTF_WITH_CORE), emit BTF now.

dwarf2out_finish
  - if (BTF_WITH_CORE) emit BTF now.

gcc/ChangeLog:

	* dwarf2ctf.c (ctf_debug_finalize): Make it static.
	(ctf_debug_early_finish): New definition.
	(ctf_debug_finish): Likewise.
	* dwarf2ctf.h (ctf_debug_finalize): Remove declaration.
	(ctf_debug_early_finish): New declaration.
	(ctf_debug_finish): Likewise.
	* dwarf2out.c (dwarf2out_finish): Invoke ctf_debug_finish.
	(dwarf2out_early_finish): Invoke ctf_debug_early_finish.
---
 gcc/dwarf2ctf.c | 54 +++++++++++++++++++++++++++++++++++++++++-------------
 gcc/dwarf2ctf.h |  4 +++-
 gcc/dwarf2out.c |  9 +++++++--
 3 files changed, 51 insertions(+), 16 deletions(-)

diff --git a/gcc/dwarf2ctf.c b/gcc/dwarf2ctf.c
index 5e8a725..b686baf 100644
--- a/gcc/dwarf2ctf.c
+++ b/gcc/dwarf2ctf.c
@@ -917,6 +917,27 @@ gen_ctf_type (ctf_container_ref ctfc, dw_die_ref die)
   return type_id;
 }
 
+/* Prepare for output and write out the CTF debug information.  */
+
+static void
+ctf_debug_finalize (const char *filename, bool btf)
+{
+  if (btf)
+    {
+      btf_output (filename);
+      btf_finalize ();
+    }
+
+  else
+    {
+      /* Emit the collected CTF information.  */
+      ctf_output (filename);
+
+      /* Reset the CTF state.  */
+      ctf_finalize ();
+    }
+}
+
 bool
 ctf_do_die (dw_die_ref die)
 {
@@ -966,24 +987,31 @@ ctf_debug_init_postprocess (bool btf)
     btf_init_postprocess ();
 }
 
-/* Prepare for output and write out the CTF debug information.  */
+/* Early finish CTF/BTF debug info.  */
 
 void
-ctf_debug_finalize (const char *filename, bool btf)
+ctf_debug_early_finish (const char * filename)
 {
-  if (btf)
-    {
-      btf_output (filename);
-      btf_finalize ();
-    }
+  /* Emit CTF debug info early always.  */
+  if (ctf_debug_info_level > CTFINFO_LEVEL_NONE
+      /* Emit BTF debug info early if CO-RE relocations are not
+	 required.  */
+      || (btf_debuginfo_p () && !btf_with_core_debuginfo_p ()))
+    ctf_debug_finalize (filename, btf_debuginfo_p ());
+}
 
-  else
-    {
-      /* Emit the collected CTF information.  */
-      ctf_output (filename);
+/* Finish CTF/BTF debug info emission.  */
 
-      /* Reset the CTF state.  */
-      ctf_finalize ();
+void
+ctf_debug_finish (const char * filename)
+{
+  /* 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 ());
     }
 }
 
diff --git a/gcc/dwarf2ctf.h b/gcc/dwarf2ctf.h
index a3cf567..9edbde0 100644
--- a/gcc/dwarf2ctf.h
+++ b/gcc/dwarf2ctf.h
@@ -24,13 +24,15 @@ along with GCC; see the file COPYING3.  If not see
 #define GCC_DWARF2CTF_H 1
 
 #include "dwarf2out.h"
+#include "flags.h"
 
 /* Debug Format Interface.  Used in dwarf2out.c.  */
 
 extern void ctf_debug_init (void);
 extern void ctf_debug_init_postprocess (bool);
 extern bool ctf_do_die (dw_die_ref);
-extern void ctf_debug_finalize (const char *, bool);
+extern void ctf_debug_early_finish (const char *);
+extern void ctf_debug_finish (const char *);
 
 /* Wrappers for CTF/BTF to fetch information from GCC DWARF DIE.  Used in
    ctfc.c.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 07a479f..3615e68 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -31913,6 +31913,11 @@ dwarf2out_finish (const char *filename)
   unsigned char checksum[16];
   char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES];
 
+  /* Generate CTF/BTF debug info.  */
+  if ((ctf_debug_info_level > CTFINFO_LEVEL_NONE
+       || btf_debuginfo_p ()) && lang_GNU_C ())
+    ctf_debug_finish (filename);
+
   /* Skip emitting DWARF if not required.  */
   if (!dwarf_debuginfo_p ())
     return;
@@ -32817,8 +32822,8 @@ dwarf2out_early_finish (const char *filename)
 	ctf_debug_do_cu (node->die);
       /* Post process the debug data in the CTF container if necessary.  */
       ctf_debug_init_postprocess (btf_debuginfo_p ());
-      /* Emit CTF/BTF debug info.  */
-      ctf_debug_finalize (filename, btf_debuginfo_p ());
+
+      ctf_debug_early_finish (filename);
     }
 
   /* Do not generate DWARF assembler now when not producing LTO bytecode.  */
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH,V3 0/3] Allow means for late BTF generation for BPF CO-RE
  2021-08-31 14:08 [PATCH,V3 0/3] Allow means for late BTF generation for BPF CO-RE Indu Bhagat
                   ` (2 preceding siblings ...)
  2021-08-31 14:08 ` [PATCH, V3 3/3] dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase Indu Bhagat
@ 2021-09-06  9:51 ` Richard Biener
  3 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2021-09-06  9:51 UTC (permalink / raw)
  To: Indu Bhagat; +Cc: GCC Patches

On Tue, Aug 31, 2021 at 4:10 PM Indu Bhagat via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> [Changes from V2]
> - Instead of target hook, the patch set now adds a new debug format
> BTF_WITH_CORE_DEBUG.
> - Renamed the BPF option from -mcore to -mco-re.
> - Adapted the commit logs a bit.
> [End of Changes from V2]

This version of the series is OK for trunk.

Thanks,
Richard.

>
> Hello,
>
> This patch series puts the framework in place for late BTF generation (in
> dwarf2out_finish). This is needed for the landing of BPF CO-RE support in GCC,
> patches for which were posted earlier -
> https://gcc.gnu.org/pipermail/gcc-patches/2021-August/576719.html.
>
> BPF's Compile Once - Run Everywhere (CO-RE) feature is used to make a compiled
> BPF program portable across kernel versions, all this without the need to
> recompile the BPF program. A key part of BPF CO-RE capability is the BTF debug
> info generated for them.
>
> A traditional BPF program (non CO-RE) will have a .BTF section which contains
> the type information in the BTF debug format.  In case of CO-RE, however, an
> additional section .BTF.ext section is used.  The .BTF.ext section contains
> the CO-RE relocations. A BPF loader will use the .BTF.ext section along with the
> associated .BTF section to adjust some references in the instructions of BPF
> program to ensure it is compatible with the required kernel version / headers.
>
> A .BTF.ext section contains the CO-RE relocation records. Roughly, each CO-RE
> relocation record will contain the following info:
>  - offset of BPF instruction to be patched
>  - the BTF ID of the data structure being accessed by the instruction, and
>  - an offset to the "access string" - a BTF string which encodes a series of
>    field accesses to retrieve the field of interest in the instruction.
>
> The .BTF.ext section does not have a string table of its own, so these "access
> strings" are placed in the .BTF section string table. The CO-RE relocation
> records refer to them by offset into the .BTF string table.
>
> Example of access string encoding:
>
>  struct S {
>      int a;
>      union {
>          int _unused;
>          int b;
>          char c;
>          } u[4];
>  };
>
> struct S *foo = ...;
> int x  = foo->a;          /* encoded as "0:0"     */
> int y  = foo[4]->u[2].b   /* encoded as "4:1:2:1" */
> char z = foo->u[3].c      /* encoded as "0:1:3:2" */
>
> This means that writing out of a .BTF section needs to be delayed until after
> these "access strings" have been added by the BPF backend, when CO-RE is in
> effect.
>
> High-level design
> -----------------
> - The CTF container (CTFC) is populated with the compiler-internal
> representation for the "type information" at dwarf2out_early_finish time.  This
> information is used for generation of the .BTF section.
> - For CO-RE relocation records, the information needed to generate .BTF.ext
> section is added by the BPF backend to the CTF container (CTFC) at expand time.
> - A new debug format BTF_WITH_CORE_DEBUG is being added.
> - The BPF backend updates the write_symbols variable with BTF_WITH_CORE_DEBUG
> debug format signalling the rest of the compiler that BPF/CO-RE is in effect,
> and hence the need to generate the BTF CO-RE relocation records.
> - BTF debug information is emitted late in dwarf2out_finish when
> BTF_WITH_CORE_DEBUG debug format is requested by the user (implicitly via the
> command line option -mco-re for the BPF backend).
> - Combining early BTF and late BTF/CO-RE debug information is not feasible due
> to the way BTF CO-RE format is defined and lack of linker support for the BTF
> debug format.
> - Lastly, LTO is disallowed to be used together with CO-RE for the BPF target.
>
> Testing Notes
> ------------
> - Bootstrapped and reg tested on x86_64
> - make all-gcc for --target=bpf-unknown-none; tested ctf.exp, btf.exp and bpf.exp
>
> Thanks,
>
> Indu Bhagat (3):
>   debug: add BTF_WITH_CORE_DEBUG debug format
>   bpf: Add new -mco-re option for BPF CO-RE
>   dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase
>
>  gcc/config/bpf/bpf.c                      | 25 ++++++++++++++
>  gcc/config/bpf/bpf.opt                    |  4 +++
>  gcc/dwarf2ctf.c                           | 54 +++++++++++++++++++++++--------
>  gcc/dwarf2ctf.h                           |  4 ++-
>  gcc/dwarf2out.c                           |  9 ++++--
>  gcc/flag-types.h                          |  6 +++-
>  gcc/flags.h                               |  4 +++
>  gcc/opts.c                                |  8 +++++
>  gcc/testsuite/gcc.target/bpf/core-lto-1.c |  9 ++++++
>  9 files changed, 106 insertions(+), 17 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/bpf/core-lto-1.c
>
> --
> 1.8.3.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-06  9:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 14:08 [PATCH,V3 0/3] Allow means for late BTF generation for BPF CO-RE Indu Bhagat
2021-08-31 14:08 ` [PATCH,V3 1/3] debug: add BTF_WITH_CORE_DEBUG debug format Indu Bhagat
2021-08-31 14:08 ` [PATCH,V3 2/3] bpf: Add new -mco-re option for BPF CO-RE Indu Bhagat
2021-08-31 14:08 ` [PATCH, V3 3/3] dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase Indu Bhagat
2021-09-06  9:51 ` [PATCH,V3 0/3] Allow means for late BTF generation for BPF CO-RE Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).