This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFA] dwarf2out.c: Add support for DWARF 3 64-bit sections
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: kevinb at redhat dot com
- Date: Fri, 7 Mar 2003 17:33:24 -0700
- Subject: [RFA] dwarf2out.c: Add support for DWARF 3 64-bit sections
The patch below adds support for 64-bit sections as specified by the
DWARF 3 (draft) standard:
http://www.eagercon.com/dwarf/Dwarf3-draft7-011029.pdf
I have bootstrapped and regression tested this patch on i386 GNU/Linux
with no problems found.
In addition, I've tested this on a little endian n64 MIPS target and
have found that gdb is now able to read 64-bit DWARF sections that it
previously could not. This is due to the fact that while gdb has some
limited support for legacy big endian 64-bit DWARF (i.e. Irix)
sections, it has no support for the equivalent, non standard,
little endian ones. A patch to gdb which added a hack for the
corresponding little endian case was recently rejected. To be
perfectly clear, gdb already *does* have support for 64-bit sections
(both big and little endian) that conform to the DWARF 3 (draft)
specification.
I should note that DWARF_COMPILE_UNIT_HEADER_SIZE needs to take the
size of the ``initial length'' field into account, but that
DWARF_PUBNAMES_HEADER_SIZE and DWARF_ARANGES_HEADER_SIZE (apparently
by design) do not. This is why DWARF_COMPILE_UNIT_HEADER size needed
to be modified but the other definitions did not.
Okay?
* dwarf2out.c (DWARF_INITIAL_LENGTH_SIZE): Define.
(DWARF_COMPILE_UNIT_HEADER_SIZE): Take into account
DWARF_INITIAL_LENGTH_SIZE.
(output_compilation_unit_header, output_pubnames, output_aranges)
(output_line_info): Output 0xffffffff escape value for 64-bit
DWARF extension.
* config/mips/iris6.h (DWARF_INITIAL_LENGTH_SIZE): Define.
Index: gcc/dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.406
diff -u -p -r1.406 dwarf2out.c
--- gcc/dwarf2out.c 6 Mar 2003 10:23:46 -0000 1.406
+++ gcc/dwarf2out.c 7 Mar 2003 23:51:30 -0000
@@ -257,6 +257,18 @@ dw_fde_node;
#define DWARF_OFFSET_SIZE 4
#endif
+/* According to the (draft) DWARF 3 specification, the initial length
+ should either be 4 or 12 bytes. When it's 12 bytes, the first 4
+ bytes are 0xffffffff, followed by the length stored in the next 8
+ bytes.
+
+ However, the SGI/MIPS ABI uses an initial length which is equal to
+ DWARF_OFFSET_SIZE. It is defined (elsewhere) accordingly. */
+
+#ifndef DWARF_INITIAL_LENGTH_SIZE
+#define DWARF_INITIAL_LENGTH_SIZE (DWARF_OFFSET_SIZE == 4 ? 4 : 12)
+#endif
+
#define DWARF_VERSION 2
/* Round SIZE up to the nearest BOUNDARY. */
@@ -3397,7 +3409,8 @@ limbo_die_node;
language, and compiler version. */
/* Fixed size portion of the DWARF compilation unit header. */
-#define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
+#define DWARF_COMPILE_UNIT_HEADER_SIZE \
+ (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 3)
/* Fixed size portion of public names info. */
#define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
@@ -6912,7 +6925,11 @@ output_die (die)
static void
output_compilation_unit_header ()
{
- dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset - DWARF_OFFSET_SIZE,
+ if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+ dw2_asm_output_data (4, 0xffffffff,
+ "Initial length escape value indicating 64-bit DWARF extension");
+ dw2_asm_output_data (DWARF_OFFSET_SIZE,
+ next_die_offset - DWARF_INITIAL_LENGTH_SIZE,
"Length of Compilation Unit Info");
dw2_asm_output_data (2, DWARF_VERSION, "DWARF version number");
dw2_asm_output_offset (DWARF_OFFSET_SIZE, abbrev_section_label,
@@ -7023,6 +7040,9 @@ output_pubnames ()
unsigned i;
unsigned long pubnames_length = size_of_pubnames ();
+ if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+ dw2_asm_output_data (4, 0xffffffff,
+ "Initial length escape value indicating 64-bit DWARF extension");
dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
"Length of Public Names Info");
dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
@@ -7081,6 +7101,9 @@ output_aranges ()
unsigned i;
unsigned long aranges_length = size_of_aranges ();
+ if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+ dw2_asm_output_data (4, 0xffffffff,
+ "Initial length escape value indicating 64-bit DWARF extension");
dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length,
"Length of Address Ranges Info");
dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
@@ -7526,6 +7549,9 @@ output_line_info ()
ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, 0);
+ if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+ dw2_asm_output_data (4, 0xffffffff,
+ "Initial length escape value indicating 64-bit DWARF extension");
dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
"Length of Source Line Info");
ASM_OUTPUT_LABEL (asm_out_file, l1);
Index: gcc/config/mips/iris6.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris6.h,v
retrieving revision 1.57
diff -u -p -r1.57 iris6.h
--- gcc/config/mips/iris6.h 19 Feb 2003 16:39:04 -0000 1.57
+++ gcc/config/mips/iris6.h 7 Mar 2003 23:51:32 -0000
@@ -160,6 +160,13 @@ Boston, MA 02111-1307, USA. */
specification. The SGI/MIPS ABI defines it to be the same as PTR_SIZE. */
#define DWARF_OFFSET_SIZE PTR_SIZE
+/* The size in bytes of the initial length field in a debug info
+ section. The DWARF 3 (draft) specification defines this to be
+ either 4 or 12 (with a 4-byte "escape" word when it's 12), but the
+ SGI/MIPS ABI predates this standard and defines it to be the same
+ as DWARF_OFFSET_SIZE. */
+#define DWARF_INITIAL_LENGTH_SIZE DWARF_OFFSET_SIZE
+
/* There is no GNU as port for Irix6 yet, so we set MD_EXEC_PREFIX so that
gcc will automatically find SGI as instead of searching the user's path.
The latter can fail when building a cross compiler if the user has . in