This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] DWARF: Add .debug_addr table header for dwarf_version >= 5.


GNU DebugFission didn't add table headers for the .debug_addr
tables, but DWARF5 does. The table header make it possible
for a DWARF consumer to parse the address tables without having
to index all .debug_info CUs first. We can keep using the
.debug_addr section label as is, because the DW_AT_addr_base
attribute points at the actual address index, which starts
right after the table header. So the label is generated at
the correct location whether the header is added first or not.

gcc/ChangeLog

	* dwarf2out.c (dwarf2out_finish): Add .debug_addr table header for
	dwarf_version >= 5.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index d3d925d..51d0ca4 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -31293,6 +31293,21 @@ dwarf2out_finish (const char *)
 	}
 
       switch_to_section (debug_addr_section);
+      /* GNU DebugFission didn't have a header for .debug_addr.  */
+      if (dwarf_version >= 5)
+	{
+	  unsigned long addrs_length =
+	    addr_index_table->elements () * DWARF2_ADDR_SIZE + 4;
+
+	  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+	    dw2_asm_output_data (4, 0xffffffff,
+				 "Escape value for 64-bit DWARF extension");
+	  dw2_asm_output_data (DWARF_OFFSET_SIZE, addrs_length,
+			       "Length of Address Unit");
+	  dw2_asm_output_data (2, 5, "DWARF addr version");
+	  dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address");
+	  dw2_asm_output_data (1, 0, "Size of Segment Descriptor");
+	}
       ASM_OUTPUT_LABEL (asm_out_file, debug_addr_section_label);
       output_addr_table ();
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]