Hi!

http://dwarfstd.org/ShowIssue.php?issue=161031.2
got approved today, so DWARF5 is changing and the various DW_UT_* kinds
will no longer have the same size of the headers.  So,
DW_UT_compile/DW_UT_partial shrinks by 12/16 bytes (padding 1 and padding 2
is removed; 16 bytes for 64-bit DWARF), DW_UT_type remains the same,
DW_UT_skeleton/DW_UT_split_compile shrink by 4/8 bytes (padding 2 is
removed).  For DW_UT_* kinds consumers don't understand, the first 3 fields
(length, version and ut kind) are required to be present and the only
sensible action is to skip the whole unit (using length field).

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Jan/Mark, are you going to adjust GDB/elfutils etc. correspondingly?

2017-01-03  Jakub Jelinek  <ja...@redhat.com>

        * dwarf2out.c (DWARF_COMPILE_UNIT_HEADER_SIZE): For DWARF5 decrease
        by 12.
        (DWARF_COMDAT_TYPE_UNIT_HEADER_SIZE): Always
        DWARF_COMPILE_UNIT_HEADER_SIZE plus 12.
        (DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE): Define.
        (calc_base_type_die_sizes): Use DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE
        for initial die_offset if dwarf_split_debug_info.
        (output_comp_unit): Use DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE for
        initial next_die_offset if dwo_id is non-NULL.  Don't emit padding
        fields.
        (output_skeleton_debug_sections): Formatting fix.  Use
        DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE instead of
        DWARF_COMPILE_UNIT_HEADER_SIZE.  Don't emit padding.

--- gcc/dwarf2out.c.jj  2017-01-03 16:04:17.000000000 +0100
+++ gcc/dwarf2out.c     2017-01-03 19:41:45.526194592 +0100
@@ -2996,14 +2996,16 @@ skeleton_chain_node;
 /* Fixed size portion of the DWARF compilation unit header.  */
 #define DWARF_COMPILE_UNIT_HEADER_SIZE \
   (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE                       \
-   + (dwarf_version >= 5                                               \
-      ? 4 + DWARF_TYPE_SIGNATURE_SIZE + DWARF_OFFSET_SIZE : 3))
+   + (dwarf_version >= 5 ? 4 : 3))
 
 /* Fixed size portion of the DWARF comdat type unit header.  */
 #define DWARF_COMDAT_TYPE_UNIT_HEADER_SIZE \
   (DWARF_COMPILE_UNIT_HEADER_SIZE                                      \
-   + (dwarf_version >= 5                                               \
-      ? 0 : DWARF_TYPE_SIGNATURE_SIZE + DWARF_OFFSET_SIZE))
+   + DWARF_TYPE_SIGNATURE_SIZE + DWARF_OFFSET_SIZE)
+
+/* Fixed size portion of the DWARF skeleton compilation unit header.  */
+#define DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE \
+  (DWARF_COMPILE_UNIT_HEADER_SIZE + (dwarf_version >= 5 ? 8 : 0))
 
 /* Fixed size portion of public names info.  */
 #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
@@ -9044,7 +9046,9 @@ calc_die_sizes (dw_die_ref die)
 static void
 calc_base_type_die_sizes (void)
 {
-  unsigned long die_offset = DWARF_COMPILE_UNIT_HEADER_SIZE;
+  unsigned long die_offset = (dwarf_split_debug_info
+                             ? DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE
+                             : DWARF_COMPILE_UNIT_HEADER_SIZE);
   unsigned int i;
   dw_die_ref base_type;
 #if ENABLE_ASSERT_CHECKING
@@ -10302,7 +10306,9 @@ output_comp_unit (dw_die_ref die, int ou
   delete extern_map;
 
   /* Initialize the beginning DIE offset - and calculate sizes/offsets.  */
-  next_die_offset = DWARF_COMPILE_UNIT_HEADER_SIZE;
+  next_die_offset = (dwo_id
+                    ? DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE
+                    : DWARF_COMPILE_UNIT_HEADER_SIZE);
   calc_die_sizes (die);
 
   oldsym = die->die_id.die_symbol;
@@ -10330,12 +10336,6 @@ output_comp_unit (dw_die_ref die, int ou
       if (dwo_id != NULL)
        for (int i = 0; i < 8; i++)
          dw2_asm_output_data (1, dwo_id[i], i == 0 ? "DWO id" : NULL);
-      else
-       /* Hope all the padding will be removed for DWARF 5 final for
-          DW_AT_compile and DW_AT_partial.  */
-       dw2_asm_output_data (8, 0, "Padding 1");
-
-      dw2_asm_output_data (DWARF_OFFSET_SIZE, 0, "Padding 2");
     }
   output_die (die);
 
@@ -10430,10 +10430,11 @@ output_skeleton_debug_sections (dw_die_r
      header.  */
   if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
     dw2_asm_output_data (4, 0xffffffff,
-      "Initial length escape value indicating 64-bit DWARF extension");
+                        "Initial length escape value indicating 64-bit "
+                        "DWARF extension");
 
   dw2_asm_output_data (DWARF_OFFSET_SIZE,
-                       DWARF_COMPILE_UNIT_HEADER_SIZE
+                      DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE
                        - DWARF_INITIAL_LENGTH_SIZE
                        + size_of_die (comp_unit),
                       "Length of Compilation Unit Info");
@@ -10449,12 +10450,8 @@ output_skeleton_debug_sections (dw_die_r
   if (dwarf_version < 5)
     dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
   else
-    {
-      for (int i = 0; i < 8; i++)
-       dw2_asm_output_data (1, dwo_id[i], i == 0 ? "DWO id" : NULL);
-
-      dw2_asm_output_data (DWARF_OFFSET_SIZE, 0, "Padding 2");
-    }
+    for (int i = 0; i < 8; i++)
+      dw2_asm_output_data (1, dwo_id[i], i == 0 ? "DWO id" : NULL);
 
   comp_unit->die_abbrev = SKELETON_COMP_DIE_ABBREV;
   output_die (comp_unit);

        Jakub

Reply via email to