diff mbox

Remove DWARF_OFFSET_SIZE, DWARF_INITIAL_LENGTH_SIZE

Message ID yddy5r3dv7g.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth March 14, 2012, 4:05 p.m. UTC
Jason Merrill <jason@redhat.com> writes:

> On 03/12/2012 01:41 PM, Joseph S. Myers wrote:
>> As a *target macro* it makes sense to remove it - reomve it from
>> defaults.h, make it purely internal to dwarf2out.c.  But I think it makes
>> sense to have it inside dwarf2out.c
>
> Agreed.

Here's the revised patch.  Bootstrapped without regressions on
i386-pc-solaris2.10, ok for mainline?

	Rainer


2012-03-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* defaults.h (DWARF_OFFSET_SIZE): Move ...
	* dwarf2out.c (DWARF_OFFSET_SIZE): ... here.
	Define unconditionally.
	(DWARF_INITIAL_LENGTH_SIZE): Hardcode default.
	(DWARF_CIE_ID): Remove non-default DWARF_OFFSET_SIZE handling.
	(DW_FORM_data): Remove.
	(DW_FORM_ref): Remove.
	(output_fde): Remove non-default DWARF_INITIAL_LENGTH_SIZE,
	DWARF_OFFSET_SIZE handling.
	(output_call_frame_info): Likewise.
	(value_format): Likewise.
	Replace DW_FORM_data by DW_FORM_data4.
	Replace DW_FORM_ref by DW_FORM_ref4.
	(output_compilation_unit_header): Remove non-default
	DWARF_INITIAL_LENGTH_SIZE, DWARF_OFFSET_SIZE handling.
	(output_pubnames): Likewise.
	(output_aranges): Likewise.
	(output_line_info): Likewise.
	(output_macinfo_op): Likewise.
	(optimize_macinfo_range): Likewise.
	(output_macinfo): Likewise.
	* config/sparc/freebsd.h (DWARF_OFFSET_SIZE): Remove comment.
	* config/sparc/linux64.h : Remove comment.
	* config/sparc/linux64.h : Likewise.

Comments

Joseph Myers March 14, 2012, 4:36 p.m. UTC | #1
On Wed, 14 Mar 2012, Rainer Orth wrote:

> Jason Merrill <jason@redhat.com> writes:
> 
> > On 03/12/2012 01:41 PM, Joseph S. Myers wrote:
> >> As a *target macro* it makes sense to remove it - reomve it from
> >> defaults.h, make it purely internal to dwarf2out.c.  But I think it makes
> >> sense to have it inside dwarf2out.c
> >
> > Agreed.
> 
> Here's the revised patch.  Bootstrapped without regressions on
> i386-pc-solaris2.10, ok for mainline?

No, I don't think you should simplify all the things you are simplifying 
inside dwarf2out.c.  The initial length really is a function of the offset 
size, not a magic constant 4, and the same applies to all the other things 
you are changing: they are not constants in DWARF so should not be treated 
as such.

I think you should move the definition of DWARF_OFFSET_SIZE into 
dwarf2out.c - with a comment that GCC doesn't generate 64-bit DWARF since 
it's only needed if you have more than 2GB of debug info in a section in a 
single .o file (or something like that) and not change anything else in 
dwarf2out.c.
Rainer Orth March 14, 2012, 4:40 p.m. UTC | #2
"Joseph S. Myers" <joseph@codesourcery.com> writes:

> On Wed, 14 Mar 2012, Rainer Orth wrote:
>
>> Jason Merrill <jason@redhat.com> writes:
>> 
>> > On 03/12/2012 01:41 PM, Joseph S. Myers wrote:
>> >> As a *target macro* it makes sense to remove it - reomve it from
>> >> defaults.h, make it purely internal to dwarf2out.c.  But I think it makes
>> >> sense to have it inside dwarf2out.c
>> >
>> > Agreed.
>> 
>> Here's the revised patch.  Bootstrapped without regressions on
>> i386-pc-solaris2.10, ok for mainline?
>
> No, I don't think you should simplify all the things you are simplifying 
> inside dwarf2out.c.  The initial length really is a function of the offset 
> size, not a magic constant 4, and the same applies to all the other things 
> you are changing: they are not constants in DWARF so should not be treated 
> as such.
>
> I think you should move the definition of DWARF_OFFSET_SIZE into 
> dwarf2out.c - with a comment that GCC doesn't generate 64-bit DWARF since 
> it's only needed if you have more than 2GB of debug info in a section in a 
> single .o file (or something like that) and not change anything else in 
> dwarf2out.c.

Ok, I'll leave that to one of the DWARF maintainers.  Patch withdrawn.

	Rainer
diff mbox

Patch

# HG changeset patch
# Parent 1e36853765843a5d65f6a1967bddab425338fd2a
Remove DWARF_OFFSET_SIZE, DWARF_INITIAL_LENGTH_SIZE

diff --git a/gcc/config/sparc/freebsd.h b/gcc/config/sparc/freebsd.h
--- a/gcc/config/sparc/freebsd.h
+++ b/gcc/config/sparc/freebsd.h
@@ -1,5 +1,5 @@ 
 /* Definitions for Sun SPARC64 running FreeBSD using the ELF format
-   Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2010, 2011
+   Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by David E. O'Brien <obrien@FreeBSD.org> and BSDi.
 
@@ -124,15 +124,6 @@  along with GCC; see the file COPYING3.  
 #undef  DBX_CONTIN_CHAR
 #define DBX_CONTIN_CHAR	'?'
 
-/* DWARF bits.  */
-
-/* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets. 
-   Obviously the Dwarf2 folks havn't tried to actually build systems
-   with their spec.  On a 64-bit system, only 64-bit relocs become
-   RELATIVE relocations.  */
-
-/* #define DWARF_OFFSET_SIZE PTR_SIZE */
-
 #ifdef HAVE_AS_TLS
 #undef TARGET_SUN_TLS
 #undef TARGET_GNU_TLS
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -1,6 +1,6 @@ 
 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
    Copyright 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011 Free Software Foundation, Inc.
+   2009, 2010, 2011, 2012 Free Software Foundation, Inc.
    Contributed by David S. Miller (davem@caip.rutgers.edu)
 
 This file is part of GCC.
@@ -236,15 +236,6 @@  do {									\
 #undef  LOCAL_LABEL_PREFIX
 #define LOCAL_LABEL_PREFIX  "."
 
-/* DWARF bits.  */
-
-/* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets. 
-   Obviously the Dwarf2 folks haven't tried to actually build systems
-   with their spec.  On a 64-bit system, only 64-bit relocs become
-   RELATIVE relocations.  */
-
-/* #define DWARF_OFFSET_SIZE PTR_SIZE */
-
 #undef DITF_CONVERSION_LIBFUNCS
 #define DITF_CONVERSION_LIBFUNCS 1
 
diff --git a/gcc/defaults.h b/gcc/defaults.h
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -462,14 +462,6 @@  see the files COPYING3 and COPYING.RUNTI
 #define DWARF2_ADDR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
 #endif
 
-/* The size in bytes of a DWARF field indicating an offset or length
-   relative to a debug info section, specified to be 4 bytes in the
-   DWARF-2 specification.  The SGI/MIPS ABI defines it to be the same
-   as PTR_SIZE.  */
-#ifndef DWARF_OFFSET_SIZE
-#define DWARF_OFFSET_SIZE 4
-#endif
-
 /* The size in bytes of a DWARF 4 type signature.  */
 #ifndef DWARF_TYPE_SIGNATURE_SIZE
 #define DWARF_TYPE_SIGNATURE_SIZE 8
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -162,17 +162,20 @@  static GTY(()) section *debug_frame_sect
 /* Maximum size (in bytes) of an artificially generated label.  */
 #define MAX_ARTIFICIAL_LABEL_BYTES	30
 
+/* The size in bytes of a DWARF field indicating an offset or length
+   relative to a debug info section, specified to be 4 bytes in the
+   DWARF-2 specification.  The SGI/MIPS ABI defined it to be the same
+   as PTR_SIZE, but that is no longer supported.  */
+#define DWARF_OFFSET_SIZE 4
+
 /* 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
+   DWARF_OFFSET_SIZE, but that is no longer supported.  */
+#define DWARF_INITIAL_LENGTH_SIZE 4
 
 /* Round SIZE up to the nearest BOUNDARY.  */
 #define DWARF_ROUND(SIZE,BOUNDARY) \
@@ -180,8 +183,7 @@  static GTY(()) section *debug_frame_sect
 
 /* CIE identifier.  */
 #if HOST_BITS_PER_WIDE_INT >= 64
-#define DWARF_CIE_ID \
-  (unsigned HOST_WIDE_INT) (DWARF_OFFSET_SIZE == 4 ? DW_CIE_ID : DW64_CIE_ID)
+#define DWARF_CIE_ID (unsigned HOST_WIDE_INT) DW_CIE_ID
 #else
 #define DWARF_CIE_ID DW_CIE_ID
 #endif
@@ -225,10 +227,6 @@  static void dwarf2out_note_section_used 
    personality CFI.  */
 static GTY(()) rtx current_unit_personality;
 
-/* Data and reference forms for relocatable data.  */
-#define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4)
-#define DW_FORM_ref (DWARF_OFFSET_SIZE == 8 ? DW_FORM_ref8 : DW_FORM_ref4)
-
 #ifndef DEBUG_FRAME_SECTION
 #define DEBUG_FRAME_SECTION	".debug_frame"
 #endif
@@ -530,11 +528,7 @@  output_fde (dw_fde_ref fde, bool for_eh,
 				  for_eh + j);
   ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + j);
   ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + j);
-  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4 && !for_eh)
-    dw2_asm_output_data (4, 0xffffffff, "Initial length escape value"
-			 " indicating 64-bit DWARF extension");
-  dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
-			"FDE Length");
+  dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1, "FDE Length");
   ASM_OUTPUT_LABEL (asm_out_file, l1);
 
   if (for_eh)
@@ -730,17 +724,13 @@  output_call_frame_info (int for_eh)
   /* Output the CIE.  */
   ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh);
   ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh);
-  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4 && !for_eh)
-    dw2_asm_output_data (4, 0xffffffff,
-      "Initial length escape value indicating 64-bit DWARF extension");
-  dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
+  dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
 			"Length of Common Information Entry");
   ASM_OUTPUT_LABEL (asm_out_file, l1);
 
   /* Now that the CIE pointer is PC-relative for EH,
      use 0 to identify the CIE.  */
-  dw2_asm_output_data ((for_eh ? 4 : DWARF_OFFSET_SIZE),
-		       (for_eh ? 0 : DWARF_CIE_ID),
+  dw2_asm_output_data (DWARF_OFFSET_SIZE, (for_eh ? 0 : DWARF_CIE_ID),
 		       "CIE Identifier Tag");
 
   /* Use the CIE version 3 for DWARF3; allow DWARF2 to continue to
@@ -7983,15 +7973,7 @@  value_format (dw_attr_ref a)
       /* FALLTHRU */
     case dw_val_class_vms_delta:
     case dw_val_class_offset:
-      switch (DWARF_OFFSET_SIZE)
-	{
-	case 4:
-	  return DW_FORM_data4;
-	case 8:
-	  return DW_FORM_data8;
-	default:
-	  gcc_unreachable ();
-	}
+      return DW_FORM_data4;
     case dw_val_class_loc:
       if (dwarf_version >= 4)
 	return DW_FORM_exprloc;
@@ -8071,14 +8053,14 @@  value_format (dw_attr_ref a)
       if (AT_ref_external (a))
 	return use_debug_types ? DW_FORM_ref_sig8 : DW_FORM_ref_addr;
       else
-	return DW_FORM_ref;
+	return DW_FORM_ref4;
     case dw_val_class_fde_ref:
-      return DW_FORM_data;
+      return DW_FORM_data4;
     case dw_val_class_lbl_id:
       return DW_FORM_addr;
     case dw_val_class_lineptr:
     case dw_val_class_macptr:
-      return dwarf_version >= 4 ? DW_FORM_sec_offset : DW_FORM_data;
+      return dwarf_version >= 4 ? DW_FORM_sec_offset : DW_FORM_data4;
     case dw_val_class_str:
       return AT_string_form (a);
     case dw_val_class_file:
@@ -8542,9 +8524,6 @@  output_compilation_unit_header (void)
 {
   int ver = dwarf_version;
 
-  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");
@@ -8749,9 +8728,6 @@  output_pubnames (VEC (pubname_entry, gc)
   unsigned long pubnames_length = size_of_pubnames (names);
   pubname_ref pub;
 
-  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
-    dw2_asm_output_data (4, 0xffffffff,
-      "Initial length escape value indicating 64-bit DWARF extension");
   if (names == pubname_table)
     dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
 			 "Length of Public Names Info");
@@ -8795,9 +8771,6 @@  output_aranges (unsigned long aranges_le
 {
   unsigned i;
 
-  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");
   /* Version number for aranges is still 2, even in DWARF3.  */
@@ -9476,9 +9449,6 @@  output_line_info (void)
   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);
@@ -20861,7 +20831,7 @@  optimize_macinfo_range (unsigned int idx
   /* The group name format is: wmN.[<encoded filename>.]<lineno>.<md5sum>  */
   grp_name = XALLOCAVEC (char, 4 + encoded_filename_len + linebuf_len + 1
 			 + 16 * 2 + 1);
-  memcpy (grp_name, DWARF_OFFSET_SIZE == 4 ? "wm4." : "wm8.", 4);
+  memcpy (grp_name, "wm4.", 4);
   tail = grp_name + 4;
   if (encoded_filename_len)
     {
@@ -20938,10 +20908,7 @@  output_macinfo (void)
   if (!dwarf_strict)
     {
       dw2_asm_output_data (2, 4, "DWARF macro version number");
-      if (DWARF_OFFSET_SIZE == 8)
-	dw2_asm_output_data (1, 3, "Flags: 64-bit, lineptr present");
-      else
-	dw2_asm_output_data (1, 2, "Flags: 32-bit, lineptr present");
+      dw2_asm_output_data (1, 2, "Flags: 32-bit, lineptr present");
       dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_line_section_label,
 			     debug_line_section, NULL);
     }
@@ -21025,10 +20992,7 @@  output_macinfo (void)
 	  ref->code = 0;
 	  ref->info = NULL;
 	  dw2_asm_output_data (2, 4, "DWARF macro version number");
-	  if (DWARF_OFFSET_SIZE == 8)
-	    dw2_asm_output_data (1, 1, "Flags: 64-bit");
-	  else
-	    dw2_asm_output_data (1, 0, "Flags: 32-bit");
+	  dw2_asm_output_data (1, 0, "Flags: 32-bit");
 	}
 	break;
       case DW_MACINFO_define: