This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

[RFA] Add support for 64-bit DWARF 2 formats to gas


The patch below adds support for 64-bit DWARF 2 formats to dwarf2dbg.c
and causes the 64-bit format used by Irix to be used for mips/n64. (See
the doc/internals.texi portion of the patch for more info.)

Okay?

	* dwarf2dbg.h (dwarf2_format): New enum.
	* dwarf2dbg.c (DWARF2_FORMAT): Provide default definition.
	(out_debug_line, out_debug_info): Add code for handling 64-bit
	DWARF 2 formats.
	* config/tc-mips.h (mips_dwarf2_format): Declare.
	* config/tc-mips.c (mips_dwarf2_format): New function.
	* doc/internals.texi (DWARF2_FORMAT): Document.

Index: dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.54
diff -u -p -r1.54 dwarf2dbg.c
--- dwarf2dbg.c	17 Sep 2002 02:55:57 -0000	1.54
+++ dwarf2dbg.c	15 Nov 2002 23:49:33 -0000
@@ -43,6 +43,10 @@
 
 #include "dwarf2dbg.h"
 
+#ifndef DWARF2_FORMAT
+#define DWARF2_FORMAT() dwarf2_format_32bit
+#endif
+
 #ifdef BFD_ASSEMBLER
 
 #include "subsegs.h"
@@ -999,6 +1003,8 @@ out_debug_line (line_seg)
   symbolS *prologue_end;
   symbolS *line_end;
   struct line_seg *s;
+  enum dwarf2_format d2f;
+  int sizeof_offset;
 
   subseg_set (line_seg, 0);
 
@@ -1010,8 +1016,31 @@ out_debug_line (line_seg)
   expr.X_op = O_subtract;
   expr.X_add_symbol = line_end;
   expr.X_op_symbol = line_start;
-  expr.X_add_number = -4;
-  emit_expr (&expr, 4);
+
+  d2f = DWARF2_FORMAT ();
+  if (d2f == dwarf2_format_32bit)
+    {
+      expr.X_add_number = -4;
+      emit_expr (&expr, 4);
+      sizeof_offset = 4;
+    }
+  else if (d2f == dwarf2_format_64bit)
+    {
+      expr.X_add_number = -12;
+      out_four (-1);
+      emit_expr (&expr, 8);
+      sizeof_offset = 8;
+    }
+  else if (d2f == dwarf2_format_64bit_irix)
+    {
+      expr.X_add_number = -8;
+      emit_expr (&expr, 8);
+      sizeof_offset = 8;
+    }
+  else
+    {
+      as_fatal (_("internal error: unknown dwarf2 format"));
+    }
 
   /* Version.  */
   out_two (2);
@@ -1021,7 +1050,7 @@ out_debug_line (line_seg)
   expr.X_add_symbol = prologue_end;
   expr.X_op_symbol = line_start;
   expr.X_add_number = - (4 + 2 + 4);
-  emit_expr (&expr, 4);
+  emit_expr (&expr, sizeof_offset);
 
   /* Parameters of the state machine.  */
   out_byte (DWARF2_LINE_MIN_INSN_LENGTH);
@@ -1174,6 +1203,8 @@ out_debug_info (info_seg, abbrev_seg, li
   symbolS *info_end;
   char *p;
   int len;
+  enum dwarf2_format d2f;
+  int sizeof_offset;
 
   subseg_set (info_seg, 0);
 
@@ -1184,8 +1215,31 @@ out_debug_info (info_seg, abbrev_seg, li
   expr.X_op = O_subtract;
   expr.X_add_symbol = info_end;
   expr.X_op_symbol = info_start;
-  expr.X_add_number = -4;
-  emit_expr (&expr, 4);
+
+  d2f = DWARF2_FORMAT ();
+  if (d2f == dwarf2_format_32bit)
+    {
+      expr.X_add_number = -4;
+      emit_expr (&expr, 4);
+      sizeof_offset = 4;
+    }
+  else if (d2f == dwarf2_format_64bit)
+    {
+      expr.X_add_number = -12;
+      out_four (-1);
+      emit_expr (&expr, 8);
+      sizeof_offset = 8;
+    }
+  else if (d2f == dwarf2_format_64bit_irix)
+    {
+      expr.X_add_number = -8;
+      emit_expr (&expr, 8);
+      sizeof_offset = 8;
+    }
+  else
+    {
+      as_fatal (_("internal error: unknown dwarf2 format"));
+    }
 
   /* DWARF version.  */
   out_two (2);
@@ -1194,7 +1248,7 @@ out_debug_info (info_seg, abbrev_seg, li
   expr.X_op = O_symbol;
   expr.X_add_symbol = section_symbol (abbrev_seg);
   expr.X_add_number = 0;
-  emit_expr (&expr, 4);
+  emit_expr (&expr, sizeof_offset);
 
   /* Target address size.  */
   out_byte (sizeof_address);
Index: dwarf2dbg.h
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.h,v
retrieving revision 1.11
diff -u -p -r1.11 dwarf2dbg.h
--- dwarf2dbg.h	14 Jun 2002 14:08:51 -0000	1.11
+++ dwarf2dbg.h	15 Nov 2002 23:49:33 -0000
@@ -69,4 +69,17 @@ extern int dwarf2dbg_estimate_size_befor
 extern int dwarf2dbg_relax_frag PARAMS ((fragS *));
 extern void dwarf2dbg_convert_frag PARAMS ((fragS *));
 
+/* An enumeration which describes the sizes of offsets (to DWARF sections)
+   and the mechanism by which the size is indicated.  */
+enum dwarf2_format {
+  /* 32-bit format: the initial length field is 4 bytes long.  */
+  dwarf2_format_32bit,
+  /* DWARF3 64-bit format: the representation of the initial length
+     (of a DWARF section) is 0xffffffff (4 bytes) followed by eight
+     bytes indicating the actual length.  */
+  dwarf2_format_64bit,
+  /* SGI extension to DWARF2: The initial length is eight bytes.  */
+  dwarf2_format_64bit_irix
+};
+
 #endif /* AS_DWARF2DBG_H */
Index: config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.177
diff -u -p -r1.177 tc-mips.c
--- config/tc-mips.c	7 Nov 2002 02:29:32 -0000	1.177
+++ config/tc-mips.c	15 Nov 2002 23:49:36 -0000
@@ -14544,3 +14544,12 @@ MIPS options:\n\
 -64			create 64 ABI object file\n"));
 #endif
 }
+
+enum dwarf2_format
+mips_dwarf2_format ()
+{
+  if (mips_abi == N64_ABI)
+    return dwarf2_format_64bit_irix;
+  else
+    return dwarf2_format_32bit;
+}
Index: config/tc-mips.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.h,v
retrieving revision 1.18
diff -u -p -r1.18 tc-mips.h
--- config/tc-mips.h	12 Oct 2002 05:23:33 -0000	1.18
+++ config/tc-mips.h	15 Nov 2002 23:49:36 -0000
@@ -182,4 +182,7 @@ extern void mips_flush_pending_output PA
 extern void mips_enable_auto_align PARAMS ((void));
 #define md_elf_section_change_hook()	mips_enable_auto_align()
 
+extern enum dwarf2_format mips_dwarf2_format PARAMS ((void));
+#define DWARF2_FORMAT() mips_dwarf2_format ()
+
 #endif /* TC_MIPS */
Index: doc/internals.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/internals.texi,v
retrieving revision 1.31
diff -u -p -r1.31 internals.texi
--- doc/internals.texi	1 Nov 2002 10:42:26 -0000	1.31
+++ doc/internals.texi	15 Nov 2002 23:49:37 -0000
@@ -1482,6 +1482,27 @@ The COFF @code{.section} directive will 
 a new section's attributes when a directive has no valid flags or when the
 flag is @code{w}. The default value of the macro is @code{SEC_LOAD | SEC_DATA}.
 
+@item DWARF2_FORMAT ()
+@cindex DWARF2_FORMAT
+If you define this, it should return one of @code{dwarf2_format_32bit},
+@code{dwarf2_format_64bit}, or @code{dwarf2_format_64bit_irix} to indicate
+the size of internal DWARF section offsets and the format of the DWARF initial
+length fields.  When @code{dwarf2_format_32bit} is returned, the initial
+length field will be 4 bytes long and section offsets are 32 bits in size.
+For @code{dwarf2_format_64bit} and @code{dwarf2_format_64bit_irix}, section
+offsets are 64 bits in size, but the initial length field differs.  An 8 byte
+initial length is indicated by @code{dwarf2_format_64bit_irix} and
+@code{dwarf2_format_64bit} indicates a 12 byte initial length field in
+which the first four bytes are 0xffffffff and the next 8 bytes are
+the section's length.
+
+If you don't define this, @code{dwarf2_format_32bit} will be used as
+the default.
+
+This define only affects @code{.debug_info} and @code{.debug_line}
+sections generated by the assembler.  DWARF 2 sections generated by
+other tools will be unaffected by this setting.
+
 @end table
 
 @node Object format backend


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