OSDN Git Service

* Makefile.in (local-distclean): Remove leftover built files.
[pf3gnuchains/gcc-fork.git] / gcc / dwarf2out.c
index 6b04b77..cb4f6f7 100644 (file)
@@ -23,9 +23,6 @@ the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
 /* TODO: Implement .debug_str handling, and share entries somehow.
-        Eliminate duplicates by putting common info in a separate section
-          to be collected by the linker and referring to it with
-          DW_FORM_ref_addr.
         Emit .debug_line header even when there are no functions, since
           the file numbers are used by .debug_info.  Alternately, leave
           out locations for types and decls.
@@ -56,17 +53,9 @@ Boston, MA 02111-1307, USA.  */
 #include "toplev.h"
 #include "varray.h"
 #include "ggc.h"
+#include "md5.h"
 #include "tm_p.h"
 
-/* We cannot use <assert.h> in GCC source, since that would include
-   GCC's assert.h, which may not be compatible with the host compiler.  */
-#undef assert
-#ifdef NDEBUG
-# define assert(e)
-#else
-# define assert(e) do { if (! (e)) abort (); } while (0)
-#endif
-
 /* Decide whether we want to emit frame unwind information for the current
    translation unit.  */
 
@@ -75,7 +64,7 @@ dwarf2out_do_frame ()
 {
   return (write_symbols == DWARF2_DEBUG
 #ifdef DWARF2_FRAME_INFO
-          || DWARF2_FRAME_INFO
+         || DWARF2_FRAME_INFO
 #endif
 #ifdef DWARF2_UNWIND_INFO
          || flag_unwind_tables
@@ -121,11 +110,11 @@ dw_cfi_node;
 /* This is how we define the location of the CFA. We use to handle it
    as REG + OFFSET all the time,  but now it can be more complex.
    It can now be either REG + CFA_OFFSET or *(REG + BASE_OFFSET) + CFA_OFFSET.
-   Instead of passing around REG and OFFSET, we pass a copy 
+   Instead of passing around REG and OFFSET, we pass a copy
    of this structure.  */
 typedef struct cfa_loc
 {
-  unsigned long reg;  
+  unsigned long reg;
   long offset;
   long base_offset;
   int indirect;            /* 1 if CFA is accessed via a dereference.  */
@@ -150,15 +139,6 @@ dw_fde_node;
 /* Maximum size (in bytes) of an artificially generated label.   */
 #define MAX_ARTIFICIAL_LABEL_BYTES     30
 
-/* Make sure we know the sizes of the various types dwarf can describe. These
-   are only defaults.  If the sizes are different for your target, you should
-   override these values by defining the appropriate symbols in your tm.h
-   file.  */
-
-#ifndef CHAR_TYPE_SIZE
-#define CHAR_TYPE_SIZE BITS_PER_UNIT
-#endif
-
 /* The size of the target's pointer type.  */
 #ifndef PTR_SIZE
 #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
@@ -189,11 +169,13 @@ dw_fde_node;
   ((((SIZE) + (BOUNDARY) - 1) / (BOUNDARY)) * (BOUNDARY))
 
 /* Offsets recorded in opcodes are a multiple of this alignment factor.  */
+#ifndef DWARF_CIE_DATA_ALIGNMENT
 #ifdef STACK_GROWS_DOWNWARD
 #define DWARF_CIE_DATA_ALIGNMENT (-((int) UNITS_PER_WORD))
 #else
 #define DWARF_CIE_DATA_ALIGNMENT ((int) UNITS_PER_WORD)
 #endif
+#endif /* not DWARF_CIE_DATA_ALIGNMENT */
 
 /* A pointer to the base of a table that contains frame description
    information for each routine.  */
@@ -221,7 +203,7 @@ static unsigned current_funcdef_number = 0;
 
 /* Some DWARF extensions (e.g., MIPS/SGI) implement a subprogram
    attribute that accelerates the lookup of the FDE associated
-   with the subprogram.  This variable holds the table index of the FDE 
+   with the subprogram.  This variable holds the table index of the FDE
    associated with the current function (body) definition.  */
 static unsigned current_funcdef_fde;
 
@@ -241,6 +223,7 @@ static void lookup_cfa                      PARAMS ((dw_cfa_location *));
 static void reg_save                   PARAMS ((const char *, unsigned,
                                                 unsigned, long));
 static void initial_return_save                PARAMS ((rtx));
+static long stack_adjust_offset                PARAMS ((rtx));
 static void output_cfi                 PARAMS ((dw_cfi_ref, dw_fde_ref));
 static void output_call_frame_info     PARAMS ((int));
 static void dwarf2out_stack_adjust     PARAMS ((rtx));
@@ -248,7 +231,7 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
 
 /* Support for complex CFA locations.  */
 static void output_cfa_loc             PARAMS ((dw_cfi_ref));
-static void get_cfa_from_loc_descr     PARAMS ((dw_cfa_location *, 
+static void get_cfa_from_loc_descr     PARAMS ((dw_cfa_location *,
                                                struct dw_loc_descr_struct *));
 static struct dw_loc_descr_struct *build_cfa_loc
                                        PARAMS ((dw_cfa_location *));
@@ -261,18 +244,18 @@ static void def_cfa_1                     PARAMS ((const char *, dw_cfa_location *));
 
 #ifdef OBJECT_FORMAT_ELF
 #ifndef UNALIGNED_SHORT_ASM_OP
-#define UNALIGNED_SHORT_ASM_OP ".2byte"
+#define UNALIGNED_SHORT_ASM_OP "\t.2byte\t"
 #endif
 #ifndef UNALIGNED_INT_ASM_OP
-#define UNALIGNED_INT_ASM_OP   ".4byte"
+#define UNALIGNED_INT_ASM_OP   "\t.4byte\t"
 #endif
 #ifndef UNALIGNED_DOUBLE_INT_ASM_OP
-#define UNALIGNED_DOUBLE_INT_ASM_OP    ".8byte"
+#define UNALIGNED_DOUBLE_INT_ASM_OP    "\t.8byte\t"
 #endif
 #endif /* OBJECT_FORMAT_ELF */
 
 #ifndef ASM_BYTE_OP
-#define ASM_BYTE_OP            ".byte"
+#define ASM_BYTE_OP            "\t.byte\t"
 #endif
 
 /* Data and reference forms for relocatable data.  */
@@ -281,7 +264,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
 
 /* Pseudo-op for defining a new section.  */
 #ifndef SECTION_ASM_OP
-#define SECTION_ASM_OP ".section"
+#define SECTION_ASM_OP "\t.section\t"
 #endif
 
 /* The default format used by the ASM_OUTPUT_SECTION macro (see below) to
@@ -292,7 +275,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
 #ifdef PUSHSECTION_FORMAT
 #define SECTION_FORMAT PUSHSECTION_FORMAT
 #else
-#define SECTION_FORMAT         "\t%s\t%s\n"
+#define SECTION_FORMAT         "%s%s\n"
 #endif
 #endif
 
@@ -312,6 +295,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
 #define FDE_AFTER_SIZE_LABEL   "LSFDE"
 #define FDE_END_LABEL          "LEFDE"
 #define FDE_LENGTH_LABEL       "LLFDE"
+#define DIE_LABEL_PREFIX       "DW"
 
 /* Definitions of defaults for various types of primitive assembly language
    output operations.  These may be overridden from within the tm.h file,
@@ -324,12 +308,12 @@ static void def_cfa_1                     PARAMS ((const char *, dw_cfa_location *));
 
 #ifndef ASM_OUTPUT_DWARF_DATA1
 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) (VALUE))
+  fprintf ((FILE), "%s0x%x", ASM_BYTE_OP, (unsigned) (VALUE))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DELTA1
 #define ASM_OUTPUT_DWARF_DELTA1(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "\t%s\t", ASM_BYTE_OP);                        \
+ do {  fprintf ((FILE), "%s", ASM_BYTE_OP);                    \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, "-");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -352,7 +336,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
 
 #ifndef ASM_OUTPUT_DWARF_DELTA2
 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP);             \
+ do {  fprintf ((FILE), "%s", UNALIGNED_SHORT_ASM_OP);                 \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, "-");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -361,7 +345,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
 
 #ifndef ASM_OUTPUT_DWARF_DELTA4
 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);               \
+ do {  fprintf ((FILE), "%s", UNALIGNED_INT_ASM_OP);                   \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, "-");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -370,7 +354,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
 
 #ifndef ASM_OUTPUT_DWARF_DELTA
 #define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2)                     \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP);            \
+ do {  fprintf ((FILE), "%s", UNALIGNED_OFFSET_ASM_OP);                \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, "-");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -379,7 +363,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
 
 #ifndef ASM_OUTPUT_DWARF_ADDR_DELTA
 #define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2)                        \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP);              \
+ do {  fprintf ((FILE), "%s", UNALIGNED_WORD_ASM_OP);                  \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, "-");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -388,7 +372,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
 
 #ifndef ASM_OUTPUT_DWARF_ADDR
 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL)                              \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP);              \
+ do {  fprintf ((FILE), "%s", UNALIGNED_WORD_ASM_OP);                  \
        assemble_name (FILE, LABEL);                                    \
   } while (0)
 #endif
@@ -396,50 +380,50 @@ static void def_cfa_1                     PARAMS ((const char *, dw_cfa_location *));
 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX)                          \
   do {                                                                 \
-    fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP);                 \
+    fprintf ((FILE), "%s", UNALIGNED_WORD_ASM_OP);                     \
     output_addr_const ((FILE), (RTX));                                 \
   } while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_OFFSET4
 #define ASM_OUTPUT_DWARF_OFFSET4(FILE,LABEL) \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);               \
+ do {  fprintf ((FILE), "%s", UNALIGNED_INT_ASM_OP);                   \
        assemble_name (FILE, LABEL);                                    \
   } while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_OFFSET
 #define ASM_OUTPUT_DWARF_OFFSET(FILE,LABEL)                            \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP);            \
+ do {  fprintf ((FILE), "%s", UNALIGNED_OFFSET_ASM_OP);                \
        assemble_name (FILE, LABEL);                                    \
   } while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA2
 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_SHORT_ASM_OP, (unsigned) (VALUE))
+  fprintf ((FILE), "%s0x%x", UNALIGNED_SHORT_ASM_OP, (unsigned) (VALUE))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA4
 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, (unsigned) (VALUE))
+  fprintf ((FILE), "%s0x%x", UNALIGNED_INT_ASM_OP, (unsigned) (VALUE))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA8
 #define ASM_OUTPUT_DWARF_DATA8(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_DOUBLE_INT_ASM_OP, \
+  fprintf ((FILE), "%s0x%lx", UNALIGNED_DOUBLE_INT_ASM_OP, \
           (unsigned long) (VALUE))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA
 #define ASM_OUTPUT_DWARF_DATA(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_OFFSET_ASM_OP, \
+  fprintf ((FILE), "%s0x%lx", UNALIGNED_OFFSET_ASM_OP, \
           (unsigned long) (VALUE))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_ADDR_DATA
 #define ASM_OUTPUT_DWARF_ADDR_DATA(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_WORD_ASM_OP, \
+  fprintf ((FILE), "%s0x%lx", UNALIGNED_WORD_ASM_OP, \
           (unsigned long) (VALUE))
 #endif
 
@@ -448,13 +432,13 @@ static void def_cfa_1                     PARAMS ((const char *, dw_cfa_location *));
   do {                                                                 \
     if (WORDS_BIG_ENDIAN)                                              \
       {                                                                        \
-       fprintf ((FILE), "\t%s\t0x%lx\n", UNALIGNED_INT_ASM_OP, (HIGH_VALUE));\
-       fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_INT_ASM_OP, (LOW_VALUE));\
+       fprintf ((FILE), "%s0x%lx\n", UNALIGNED_INT_ASM_OP, (HIGH_VALUE));\
+       fprintf ((FILE), "%s0x%lx", UNALIGNED_INT_ASM_OP, (LOW_VALUE));\
       }                                                                        \
     else                                                               \
       {                                                                        \
-       fprintf ((FILE), "\t%s\t0x%lx\n", UNALIGNED_INT_ASM_OP, (LOW_VALUE)); \
-       fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_INT_ASM_OP, (HIGH_VALUE)); \
+       fprintf ((FILE), "%s0x%lx\n", UNALIGNED_INT_ASM_OP, (LOW_VALUE)); \
+       fprintf ((FILE), "%s0x%lx", UNALIGNED_INT_ASM_OP, (HIGH_VALUE)); \
       }                                                                        \
   } while (0)
 #endif
@@ -465,7 +449,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
    .debug_frame.  But we know it won't work for .debug_info.  */
 
 #ifdef DWARF2_DEBUGGING_INFO
-#error DWARF2_DEBUGGING_INFO requires UNALIGNED_INT_ASM_OP.
+ #error DWARF2_DEBUGGING_INFO requires UNALIGNED_INT_ASM_OP.
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_ADDR
@@ -494,7 +478,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
                                   gen_rtx_SYMBOL_REF (Pmode, LABEL2)), \
                    2, 1)
 #endif
-  
+
 #ifndef ASM_OUTPUT_DWARF_DELTA4
 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2)                    \
   assemble_integer (gen_rtx_MINUS (SImode,                             \
@@ -532,7 +516,7 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
 #ifndef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO)            \
  do {                                                                  \
-  fprintf (FILE, "\t%s\t", SET_ASM_OP);                                        \
+  fprintf (FILE, "%s", SET_ASM_OP);                                    \
   assemble_name (FILE, SY);                                            \
   fputc (',', FILE);                                                   \
   assemble_name (FILE, HI);                                            \
@@ -545,10 +529,10 @@ static void def_cfa_1                     PARAMS ((const char *, dw_cfa_location *));
 /* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing
    newline is produced.  When flag_debug_asm is asserted, we add commentary
    at the end of the line, so we must avoid output of a newline here.  */
-#ifndef ASM_OUTPUT_DWARF_STRING
-#define ASM_OUTPUT_DWARF_STRING(FILE,P) \
+#ifndef ASM_OUTPUT_DWARF_NSTRING
+#define ASM_OUTPUT_DWARF_NSTRING(FILE,P,SLEN) \
   do {                                                                       \
-    register int slen = strlen(P);                                            \
+    register int slen = (SLEN);                                               \
     register const char *p = (P);                                            \
     register int i;                                                          \
     fprintf (FILE, "\t.ascii \"");                                           \
@@ -568,6 +552,8 @@ static void def_cfa_1                       PARAMS ((const char *, dw_cfa_location *));
   }                                                                          \
   while (0)
 #endif
+#define ASM_OUTPUT_DWARF_STRING(FILE,P) \
+  ASM_OUTPUT_DWARF_NSTRING (FILE, P, strlen (P))
 
 /* The DWARF 2 CFA column which tracks the return address.  Normally this
    is the column for PC, or the first column after all of the hard
@@ -745,7 +731,7 @@ dwarf2out_cfi_label ()
 {
   static char label[20];
   static unsigned long label_num = 0;
-  
+
   ASM_GENERATE_INTERNAL_LABEL (label, "LCFI", label_num++);
   ASM_OUTPUT_LABEL (asm_out_file, label);
 
@@ -922,7 +908,7 @@ def_cfa_1 (label, loc_p)
     }
   else
     {
-      struct dw_loc_descr_struct * loc_list;
+      struct dw_loc_descr_struct *loc_list;
       cfi->dw_cfi_opc = DW_CFA_def_cfa_expression;
       loc_list = build_cfa_loc (&loc);
       cfi->dw_cfi_oprnd1.dw_cfi_loc = loc_list;
@@ -958,6 +944,18 @@ reg_save (label, reg, sreg, offset)
       else
        cfi->dw_cfi_opc = DW_CFA_offset;
 
+#ifdef ENABLE_CHECKING
+      {
+       /* If we get an offset that is not a multiple of
+          DWARF_CIE_DATA_ALIGNMENT, there is either a bug in the
+          definition of DWARF_CIE_DATA_ALIGNMENT, or a bug in the machine
+          description.  */
+       long check_offset = offset / DWARF_CIE_DATA_ALIGNMENT;
+
+       if (check_offset * DWARF_CIE_DATA_ALIGNMENT != offset)
+         abort ();
+      }
+#endif
       offset /= DWARF_CIE_DATA_ALIGNMENT;
       if (offset < 0)
        {
@@ -981,7 +979,7 @@ reg_save (label, reg, sreg, offset)
 /* Add the CFI for saving a register window.  LABEL is passed to reg_save.
    This CFI tells the unwinder that it needs to restore the window registers
    from the previous frame's window save area.
-   
+
    ??? Perhaps we should note in the CIE where windows are saved (instead of
    assuming 0(cfa)) and what registers are in the window.  */
 
@@ -1103,6 +1101,50 @@ initial_return_save (rtl)
   reg_save (NULL, DWARF_FRAME_RETURN_COLUMN, reg, offset - cfa.offset);
 }
 
+/* Given a SET, calculate the amount of stack adjustment it
+   contains. */
+
+static long
+stack_adjust_offset (pattern)
+  rtx pattern;
+{
+  rtx src = SET_SRC (pattern);
+  rtx dest = SET_DEST (pattern);
+  long offset = 0;
+  enum rtx_code code;
+
+  if (dest == stack_pointer_rtx)
+    {
+      /* (set (reg sp) (plus (reg sp) (const_int))) */
+      code = GET_CODE (src);
+      if (! (code == PLUS || code == MINUS)
+         || XEXP (src, 0) != stack_pointer_rtx
+         || GET_CODE (XEXP (src, 1)) != CONST_INT)
+       return 0;
+
+      offset = INTVAL (XEXP (src, 1));
+    }
+  else if (GET_CODE (dest) == MEM)
+    {
+      /* (set (mem (pre_dec (reg sp))) (foo)) */
+      src = XEXP (dest, 0);
+      code = GET_CODE (src);
+
+      if (! (code == PRE_DEC || code == PRE_INC)
+         || XEXP (src, 0) != stack_pointer_rtx)
+       return 0;
+
+      offset = GET_MODE_SIZE (GET_MODE (dest));
+    }
+  else
+    return 0;
+
+  if (code == PLUS || code == PRE_INC)
+    offset = -offset;
+
+  return offset;
+}
+
 /* Check INSN to see if it looks like a push or a stack adjustment, and
    make a note of it if it does.  EH uses this information to find out how
    much extra space it needs to pop off the stack.  */
@@ -1123,7 +1165,8 @@ dwarf2out_stack_adjust (insn)
        insn = XVECEXP (insn, 0, 0);
       if (GET_CODE (insn) == SET)
        insn = SET_SRC (insn);
-      assert (GET_CODE (insn) == CALL);
+      if (GET_CODE (insn) != CALL)
+       abort ();
       dwarf2out_args_size ("", INTVAL (XEXP (insn, 1)));
       return;
     }
@@ -1147,41 +1190,22 @@ dwarf2out_stack_adjust (insn)
     }
   else if (GET_CODE (PATTERN (insn)) == SET)
     {
-      rtx src, dest;
-      enum rtx_code code;
-
-      insn = PATTERN (insn);
-      src = SET_SRC (insn);
-      dest = SET_DEST (insn);
-
-      if (dest == stack_pointer_rtx)
-       {
-         /* (set (reg sp) (plus (reg sp) (const_int))) */
-         code = GET_CODE (src);
-         if (! (code == PLUS || code == MINUS)
-             || XEXP (src, 0) != stack_pointer_rtx
-             || GET_CODE (XEXP (src, 1)) != CONST_INT)
-           return;
+      offset = stack_adjust_offset (PATTERN (insn));
+    }
+  else if (GET_CODE (PATTERN (insn)) == PARALLEL
+          || GET_CODE (PATTERN (insn)) == SEQUENCE)
+    {
+      /* There may be stack adjustments inside compound insns.  Search
+         for them. */
+      int j;
 
-         offset = INTVAL (XEXP (src, 1));
-       }
-      else if (GET_CODE (dest) == MEM)
+      offset = 0;
+      for (j = XVECLEN (PATTERN (insn), 0) - 1; j >= 0; j--)
        {
-         /* (set (mem (pre_dec (reg sp))) (foo)) */
-         src = XEXP (dest, 0);
-         code = GET_CODE (src);
-
-         if (! (code == PRE_DEC || code == PRE_INC)
-             || XEXP (src, 0) != stack_pointer_rtx)
-           return;
-
-         offset = GET_MODE_SIZE (GET_MODE (dest));
+         rtx pattern = XVECEXP (PATTERN (insn), 0, j);
+         if (GET_CODE (pattern) == SET)
+           offset += stack_adjust_offset (pattern);
        }
-      else
-       return;
-
-      if (code == PLUS || code == PRE_INC)
-       offset = -offset;
     }
   else
     return;
@@ -1212,7 +1236,7 @@ static long cfa_temp_value;
 
 /* Record call frame debugging information for an expression, which either
    sets SP or FP (adjusting how we calculate the frame address) or saves a
-   register to the stack. */
+   register to the stack.  */
 
 static void
 dwarf2out_frame_debug_expr (expr, label)
@@ -1221,30 +1245,30 @@ dwarf2out_frame_debug_expr (expr, label)
 {
   rtx src, dest;
   long offset;
-    
-  /* If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of 
-     the PARALLEL independently. The first element is always processed if 
-     it is a SET. This is for backward compatability.   Other elements 
-     are processed only if they are SETs and the RTX_FRAME_RELATED_P 
-     flag is set in them. */
+
+  /* If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of
+     the PARALLEL independently. The first element is always processed if
+     it is a SET. This is for backward compatability.   Other elements
+     are processed only if they are SETs and the RTX_FRAME_RELATED_P
+     flag is set in them.  */
 
   if (GET_CODE (expr) == PARALLEL
       || GET_CODE (expr) == SEQUENCE)
-    { 
+    {
       int par_index;
       int limit = XVECLEN (expr, 0);
 
       for (par_index = 0; par_index < limit; par_index++)
-        {
-          rtx x = XVECEXP (expr, 0, par_index);
-          
-          if (GET_CODE (x) == SET &&
+       {
+         rtx x = XVECEXP (expr, 0, par_index);
+
+         if (GET_CODE (x) == SET &&
              (RTX_FRAME_RELATED_P (x) || par_index == 0))
            dwarf2out_frame_debug_expr (x, label);
-        }
+       }
       return;
     }
-  
+
   if (GET_CODE (expr) != SET)
     abort ();
 
@@ -1257,25 +1281,26 @@ dwarf2out_frame_debug_expr (expr, label)
       /* Update the CFA rule wrt SP or FP.  Make sure src is
          relative to the current CFA register.  */
       switch (GET_CODE (src))
-        {
-          /* Setting FP from SP.  */
-        case REG:
-          if (cfa.reg == (unsigned) REGNO (src))
-           /* OK */;
+       {
+         /* Setting FP from SP.  */
+       case REG:
+         if (cfa.reg == (unsigned) REGNO (src))
+           /* OK.  */
+           ;
          else
-            abort ();
+           abort ();
 
          /* We used to require that dest be either SP or FP, but the
             ARM copies SP to a temporary register, and from there to
             FP.  So we just rely on the backends to only set
             RTX_FRAME_RELATED_P on appropriate insns.  */
-          cfa.reg = REGNO (dest);
-          break;
+         cfa.reg = REGNO (dest);
+         break;
 
-        case PLUS:
-        case MINUS:
-          if (dest == stack_pointer_rtx)
-            {
+       case PLUS:
+       case MINUS:
+         if (dest == stack_pointer_rtx)
+           {
              /* Adjusting SP.  */
              switch (GET_CODE (XEXP (src, 1)))
                {
@@ -1307,9 +1332,9 @@ dwarf2out_frame_debug_expr (expr, label)
                cfa.offset += offset;
              if (cfa_store.reg == STACK_POINTER_REGNUM)
                cfa_store.offset += offset;
-            }
-          else if (dest == hard_frame_pointer_rtx)
-            {
+           }
+         else if (dest == hard_frame_pointer_rtx)
+           {
              /* Either setting the FP from an offset of the SP,
                 or adjusting the FP */
              if (! frame_pointer_needed)
@@ -1325,11 +1350,11 @@ dwarf2out_frame_debug_expr (expr, label)
                  cfa.offset += offset;
                  cfa.reg = HARD_FRAME_POINTER_REGNUM;
                }
-             else 
-               abort();
-            }
-          else
-            {
+             else
+               abort ();
+           }
+         else
+           {
              if (GET_CODE (src) != PLUS
                  || XEXP (src, 1) != stack_pointer_rtx)
                abort ();
@@ -1340,26 +1365,26 @@ dwarf2out_frame_debug_expr (expr, label)
                abort ();
              cfa_store.reg = REGNO (dest);
              cfa_store.offset = cfa.offset - cfa_temp_value;
-            }
-          break;
+           }
+         break;
 
-        case CONST_INT:
-          cfa_temp_reg = REGNO (dest);
-          cfa_temp_value = INTVAL (src);
-          break;
+       case CONST_INT:
+         cfa_temp_reg = REGNO (dest);
+         cfa_temp_value = INTVAL (src);
+         break;
 
-        case IOR:
-          if (GET_CODE (XEXP (src, 0)) != REG
+       case IOR:
+         if (GET_CODE (XEXP (src, 0)) != REG
              || (unsigned) REGNO (XEXP (src, 0)) != cfa_temp_reg
              || (unsigned) REGNO (dest) != cfa_temp_reg
              || GET_CODE (XEXP (src, 1)) != CONST_INT)
-            abort ();
-          cfa_temp_value |= INTVAL (XEXP (src, 1));
-          break;
+           abort ();
+         cfa_temp_value |= INTVAL (XEXP (src, 1));
+         break;
 
-        default:
-          abort ();
-        }
+       default:
+         abort ();
+       }
       def_cfa_1 (label, &cfa);
       break;
 
@@ -1413,7 +1438,7 @@ dwarf2out_frame_debug_expr (expr, label)
          /* Without an offset.  */
        case REG:
          if (cfa_store.reg != (unsigned) REGNO (XEXP (dest, 0)))
-           abort();
+           abort ();
          offset = -cfa_store.offset;
          break;
 
@@ -1421,7 +1446,7 @@ dwarf2out_frame_debug_expr (expr, label)
          abort ();
        }
 
-      if (REGNO (src) != STACK_POINTER_REGNUM 
+      if (REGNO (src) != STACK_POINTER_REGNUM
          && REGNO (src) != HARD_FRAME_POINTER_REGNUM
          && (unsigned) REGNO (src) == cfa.reg)
        {
@@ -1464,7 +1489,6 @@ dwarf2out_frame_debug_expr (expr, label)
     }
 }
 
-
 /* Record call frame debugging information for INSN, which either
    sets SP or FP (adjusting how we calculate the frame address) or saves a
    register to the stack.  If INSN is NULL_RTX, initialize our state.  */
@@ -1496,11 +1520,11 @@ dwarf2out_frame_debug (insn)
     }
 
   label = dwarf2out_cfi_label ();
-    
+
   src = find_reg_note (insn, REG_FRAME_RELATED_EXPR, NULL_RTX);
   if (src)
     insn = XEXP (src, 0);
-  else 
+  else
     insn = PATTERN (insn);
 
   dwarf2out_frame_debug_expr (insn, label);
@@ -1555,7 +1579,7 @@ output_uleb128 (value)
 {
   unsigned long save_value = value;
 
-  fprintf (asm_out_file, "\t%s\t", ASM_BYTE_OP);
+  fprintf (asm_out_file, "%s", ASM_BYTE_OP);
   do
     {
       register unsigned byte = (value & 0x7f);
@@ -1584,7 +1608,7 @@ output_sleb128 (value)
   register unsigned byte;
   long save_value = value;
 
-  fprintf (asm_out_file, "\t%s\t", ASM_BYTE_OP);
+  fprintf (asm_out_file, "%s", ASM_BYTE_OP);
   do
     {
       byte = (value & 0x7f);
@@ -1658,8 +1682,8 @@ output_cfi (cfi, fde)
       switch (cfi->dw_cfi_opc)
        {
        case DW_CFA_set_loc:
-          ASM_OUTPUT_DWARF_ADDR (asm_out_file, cfi->dw_cfi_oprnd1.dw_cfi_addr);
-          fputc ('\n', asm_out_file);
+         ASM_OUTPUT_DWARF_ADDR (asm_out_file, cfi->dw_cfi_oprnd1.dw_cfi_addr);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_advance_loc1:
          ASM_OUTPUT_DWARF_DELTA1 (asm_out_file,
@@ -1669,17 +1693,17 @@ output_cfi (cfi, fde)
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
        case DW_CFA_advance_loc2:
-          ASM_OUTPUT_DWARF_DELTA2 (asm_out_file,
+         ASM_OUTPUT_DWARF_DELTA2 (asm_out_file,
                                   cfi->dw_cfi_oprnd1.dw_cfi_addr,
                                   fde->dw_fde_current_label);
           fputc ('\n', asm_out_file);
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
        case DW_CFA_advance_loc4:
-          ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
+         ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
                                   cfi->dw_cfi_oprnd1.dw_cfi_addr,
                                   fde->dw_fde_current_label);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
 #ifdef MIPS_DEBUGGING_INFO
@@ -1692,35 +1716,35 @@ output_cfi (cfi, fde)
        case DW_CFA_GNU_negative_offset_extended:
        case DW_CFA_def_cfa:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          output_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_restore_extended:
        case DW_CFA_undefined:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_same_value:
        case DW_CFA_def_cfa_register:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_register:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          output_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_reg_num);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_def_cfa_offset:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_GNU_window_save:
          break;
        case DW_CFA_GNU_args_size:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_def_cfa_expression:
          output_cfa_loc (cfi);
@@ -1728,7 +1752,7 @@ output_cfi (cfi, fde)
        default:
          break;
        }
-     }
+    }
 }
 
 /* Output the call frame information used to used to record information
@@ -1784,7 +1808,7 @@ output_call_frame_info (for_eh)
   else
     ASM_OUTPUT_SECTION (asm_out_file, FRAME_SECTION);
 
-  /* Output the CIE. */
+  /* Output the CIE.  */
   ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh);
   ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh);
 #ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
@@ -1897,10 +1921,10 @@ output_call_frame_info (for_eh)
       if (for_eh && fde->nothrow)
        continue;
 
-      ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i*2);
-      ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + i*2);
+      ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i * 2);
+      ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + i * 2);
 #ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
-      ASM_GENERATE_INTERNAL_LABEL (ld, FDE_LENGTH_LABEL, for_eh + i*2);
+      ASM_GENERATE_INTERNAL_LABEL (ld, FDE_LENGTH_LABEL, for_eh + i * 2);
       if (for_eh)
        ASM_OUTPUT_DWARF_OFFSET4 (asm_out_file, ld);
       else
@@ -2067,9 +2091,9 @@ dwarf2out_frame_finish ()
 #else
   if (write_symbols == DWARF2_DEBUG
       || flag_unwind_tables || (flag_exceptions && ! exceptions_via_longjmp))
-    output_call_frame_info (1);  
+    output_call_frame_info (1);
 #endif
-}  
+}
 \f
 /* And now, the subset of the debugging information support code necessary
    for emitting location expressions.  */
@@ -2132,7 +2156,10 @@ typedef struct dw_val_struct
       long unsigned val_unsigned;
       dw_long_long_const val_long_long;
       dw_float_const val_float;
-      dw_die_ref val_die_ref;
+      struct {
+       dw_die_ref die;
+       int external;
+      } val_die_ref;
       unsigned val_fde_index;
       char *val_str;
       char *val_lbl_id;
@@ -2151,6 +2178,7 @@ typedef struct dw_loc_descr_struct
   enum dwarf_location_atom dw_loc_opc;
   dw_val_node dw_loc_oprnd1;
   dw_val_node dw_loc_oprnd2;
+  int dw_loc_addr;
 }
 dw_loc_descr_node;
 
@@ -2468,7 +2496,6 @@ dwarf_stack_op_name (op)
     }
 }
 
-
 /* Return a pointer to a newly allocated location description.  Location
    descriptions are simple expression terms that can be strung
    together to form more complicated location (address) descriptions.  */
@@ -2479,10 +2506,11 @@ new_loc_descr (op, oprnd1, oprnd2)
      register unsigned long oprnd1;
      register unsigned long oprnd2;
 {
+  /* Use xcalloc here so we clear out all of the long_long constant in
+     the union.  */
   register dw_loc_descr_ref descr
-    = (dw_loc_descr_ref) xmalloc (sizeof (dw_loc_descr_node));
+    = (dw_loc_descr_ref) xcalloc (1, sizeof (dw_loc_descr_node));
 
-  descr->dw_loc_next = NULL;
   descr->dw_loc_opc = op;
   descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
   descr->dw_loc_oprnd1.v.val_unsigned = oprnd1;
@@ -2620,7 +2648,10 @@ size_of_locs (loc)
   register unsigned long size = 0;
 
   for (; loc != NULL; loc = loc->dw_loc_next)
-    size += size_of_loc_descr (loc);
+    {
+      loc->dw_loc_addr = size;
+      size += size_of_loc_descr (loc);
+    }
 
   return size;
 }
@@ -2658,8 +2689,17 @@ output_loc_operands (loc)
       break;
     case DW_OP_skip:
     case DW_OP_bra:
-      ASM_OUTPUT_DWARF_DATA2 (asm_out_file, val1->v.val_int);
-      fputc ('\n', asm_out_file);
+      {
+       int offset;
+
+       if (val1->val_class == dw_val_class_loc)
+         offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
+       else
+         abort ();
+
+       ASM_OUTPUT_DWARF_DATA2 (asm_out_file, offset);
+       fputc ('\n', asm_out_file);
+      }
       break;
 #else
     case DW_OP_addr:
@@ -2803,8 +2843,8 @@ output_cfa_loc (cfi)
   output_loc_sequence (loc);
 }
 
-/* This function builds a dwarf location descriptor seqeunce from 
-   a dw_cfa_location. */
+/* This function builds a dwarf location descriptor seqeunce from
+   a dw_cfa_location.  */
 
 static struct dw_loc_descr_struct *
 build_cfa_loc (cfa)
@@ -2816,9 +2856,16 @@ build_cfa_loc (cfa)
     abort ();
 
   if (cfa->base_offset)
-    head = new_loc_descr (DW_OP_breg0 + cfa->reg, cfa->base_offset, 0);
-  else
+    {
+      if (cfa->reg <= 31)
+       head = new_loc_descr (DW_OP_breg0 + cfa->reg, cfa->base_offset, 0);
+      else
+       head = new_loc_descr (DW_OP_bregx, cfa->reg, cfa->base_offset);
+    }
+  else if (cfa->reg <= 31)
     head = new_loc_descr (DW_OP_reg0 + cfa->reg, 0, 0);
+  else
+    head = new_loc_descr (DW_OP_regx, cfa->reg, 0);
   head->dw_loc_oprnd1.val_class = dw_val_class_const;
   tmp = new_loc_descr (DW_OP_deref, 0, 0);
   add_loc_descr (&head, tmp);
@@ -2830,15 +2877,15 @@ build_cfa_loc (cfa)
   return head;
 }
 
-/* This function fills in aa dw_cfa_location structure from a 
+/* This function fills in aa dw_cfa_location structure from a
    dwarf location descriptor sequence.  */
 
 static void
 get_cfa_from_loc_descr (cfa, loc)
      dw_cfa_location *cfa;
-     struct dw_loc_descr_struct * loc;
+     struct dw_loc_descr_struct *loc;
 {
-  struct dw_loc_descr_struct * ptr;
+  struct dw_loc_descr_struct *ptr;
   cfa->offset = 0;
   cfa->base_offset = 0;
   cfa->indirect = 0;
@@ -2848,7 +2895,7 @@ get_cfa_from_loc_descr (cfa, loc)
     {
       enum dwarf_location_atom op = ptr->dw_loc_opc;
       switch (op)
-        {
+       {
        case DW_OP_reg0:
        case DW_OP_reg1:
        case DW_OP_reg2:
@@ -2929,7 +2976,7 @@ get_cfa_from_loc_descr (cfa, loc)
          cfa->indirect = 1;
          break;
        case DW_OP_plus_uconst:
-         cfa->offset =  ptr->dw_loc_oprnd1.v.val_unsigned;
+         cfa->offset = ptr->dw_loc_oprnd1.v.val_unsigned;
          break;
        default:
          fatal ("DW_LOC_OP %s not implememnted yet.\n",
@@ -3003,12 +3050,14 @@ dw_attr_node;
 typedef struct die_struct
 {
   enum dwarf_tag die_tag;
+  char *die_symbol;
   dw_attr_ref die_attr;
   dw_die_ref die_parent;
   dw_die_ref die_child;
   dw_die_ref die_sib;
   dw_offset die_offset;
   unsigned long die_abbrev;
+  int die_mark;
 }
 die_node;
 
@@ -3017,7 +3066,7 @@ die_node;
 typedef struct pubname_struct
 {
   dw_die_ref die;
-  char * name;
+  char *name;
 }
 pubname_entry;
 
@@ -3080,10 +3129,14 @@ extern int flag_traditional;
   (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2) \
    - (2 * DWARF_OFFSET_SIZE + 4))
 
-/* The default is to have gcc emit the line number tables.  */
+/* Use assembler line directives if available.  */
 #ifndef DWARF2_ASM_LINE_DEBUG_INFO
+#ifdef HAVE_AS_DWARF2_DEBUG_LINE
+#define DWARF2_ASM_LINE_DEBUG_INFO 1
+#else
 #define DWARF2_ASM_LINE_DEBUG_INFO 0
 #endif
+#endif
 
 /* Define the architecture-dependent minimum instruction length (in bytes).
    In this implementation of DWARF, this field is used for information
@@ -3122,21 +3175,25 @@ static dw_die_ref comp_unit_die;
 /* A list of DIEs with a NULL parent waiting to be relocated.  */
 static limbo_die_node *limbo_die_list = 0;
 
-/* Pointer to an array of filenames referenced by this compilation unit.  */
-static char **file_table;
-
-/* Total number of entries in the table (i.e. array) pointed to by
-   `file_table'.  This is the *total* and includes both used and unused
-   slots.  */
-static unsigned file_table_allocated;
-
-/* Number of entries in the file_table which are actually in use.  */
-static unsigned file_table_in_use;
+/* Structure used by lookup_filename to manage sets of filenames.  */
+struct file_table
+{
+  char **table;
+  unsigned allocated;
+  unsigned in_use;
+  unsigned last_lookup_index;
+};
 
 /* Size (in elements) of increments by which we may expand the filename
    table.  */
 #define FILE_TABLE_INCREMENT 64
 
+/* Filenames referenced by declarations this compilation unit.  */
+static struct file_table decl_file_table;
+
+/* Filenames referenced by line numbers in this compilation unit.  */
+static struct file_table line_file_table;
+
 /* Local pointer to the name of the main input file.  Initialized in
    dwarf2out_init.  */
 static const char *primary_filename;
@@ -3332,6 +3389,7 @@ static unsigned get_AT_unsigned           PARAMS ((dw_die_ref,
 static inline dw_die_ref get_AT_ref    PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute));
 static int is_c_family                 PARAMS ((void));
+static int is_java                     PARAMS ((void));
 static int is_fortran                  PARAMS ((void));
 static void remove_AT                  PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute));
@@ -3345,26 +3403,46 @@ static void equate_decl_number_to_die   PARAMS ((tree, dw_die_ref));
 static void print_spaces               PARAMS ((FILE *));
 static void print_die                  PARAMS ((dw_die_ref, FILE *));
 static void print_dwarf_line_table     PARAMS ((FILE *));
+static void reverse_die_lists          PARAMS ((dw_die_ref));
+static void reverse_all_dies           PARAMS ((dw_die_ref));
+static dw_die_ref push_new_compile_unit PARAMS ((dw_die_ref, dw_die_ref));
+static dw_die_ref pop_compile_unit     PARAMS ((dw_die_ref));
+static void loc_checksum        PARAMS ((dw_loc_descr_ref, struct md5_ctx *));
+static void attr_checksum            PARAMS ((dw_attr_ref, struct md5_ctx *));
+static void die_checksum              PARAMS ((dw_die_ref, struct md5_ctx *));
+static void compute_section_prefix     PARAMS ((dw_die_ref));
+static int is_type_die                 PARAMS ((dw_die_ref));
+static int is_comdat_die               PARAMS ((dw_die_ref));
+static int is_symbol_die               PARAMS ((dw_die_ref));
+static char *gen_internal_sym          PARAMS ((void));
+static void assign_symbol_names                PARAMS ((dw_die_ref));
+static void break_out_includes         PARAMS ((dw_die_ref));
 static void add_sibling_attributes     PARAMS ((dw_die_ref));
 static void build_abbrev_table         PARAMS ((dw_die_ref));
 static unsigned long size_of_string    PARAMS ((const char *));
 static int constant_size               PARAMS ((long unsigned));
 static unsigned long size_of_die       PARAMS ((dw_die_ref));
 static void calc_die_sizes             PARAMS ((dw_die_ref));
+static void mark_dies                  PARAMS ((dw_die_ref));
+static void unmark_dies                        PARAMS ((dw_die_ref));
 static unsigned long size_of_line_prolog PARAMS ((void));
 static unsigned long size_of_pubnames  PARAMS ((void));
 static unsigned long size_of_aranges   PARAMS ((void));
 static enum dwarf_form value_format    PARAMS ((dw_attr_ref));
 static void output_value_format                PARAMS ((dw_attr_ref));
 static void output_abbrev_section      PARAMS ((void));
+static void output_die_symbol          PARAMS ((dw_die_ref));
+static void output_symbolic_ref                PARAMS ((dw_die_ref));
 static void output_die                 PARAMS ((dw_die_ref));
 static void output_compilation_unit_header PARAMS ((void));
+static void output_comp_unit           PARAMS ((dw_die_ref));
 static const char *dwarf2_name         PARAMS ((tree, int));
 static void add_pubname                        PARAMS ((tree, dw_die_ref));
 static void output_pubnames            PARAMS ((void));
 static void add_arange                 PARAMS ((tree, dw_die_ref));
 static void output_aranges             PARAMS ((void));
 static void output_line_info           PARAMS ((void));
+static void output_file_names           PARAMS ((void));
 static dw_die_ref base_type_die                PARAMS ((tree));
 static tree root_type                  PARAMS ((tree));
 static int is_base_type                        PARAMS ((tree));
@@ -3372,11 +3450,13 @@ static dw_die_ref modified_type_die     PARAMS ((tree, int, int, dw_die_ref));
 static int type_is_enum                        PARAMS ((tree));
 static unsigned int reg_number         PARAMS ((rtx));
 static dw_loc_descr_ref reg_loc_descriptor PARAMS ((rtx));
+static dw_loc_descr_ref int_loc_descriptor PARAMS ((HOST_WIDE_INT));
 static dw_loc_descr_ref based_loc_descr        PARAMS ((unsigned, long));
 static int is_based_loc                        PARAMS ((rtx));
 static dw_loc_descr_ref mem_loc_descriptor PARAMS ((rtx, enum machine_mode mode));
 static dw_loc_descr_ref concat_loc_descriptor PARAMS ((rtx, rtx));
 static dw_loc_descr_ref loc_descriptor PARAMS ((rtx));
+static dw_loc_descr_ref loc_descriptor_from_tree PARAMS ((tree, int));
 static HOST_WIDE_INT ceiling           PARAMS ((HOST_WIDE_INT, unsigned int));
 static tree field_type                 PARAMS ((tree));
 static unsigned int simple_type_align_in_bits PARAMS ((tree));
@@ -3386,7 +3466,9 @@ static void add_AT_location_description   PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute, rtx));
 static void add_data_member_location_attribute PARAMS ((dw_die_ref, tree));
 static void add_const_value_attribute  PARAMS ((dw_die_ref, rtx));
+static rtx rtl_for_decl_location       PARAMS ((tree));
 static void add_location_or_const_value_attribute PARAMS ((dw_die_ref, tree));
+static void tree_add_const_value_attribute PARAMS ((dw_die_ref, tree));
 static void add_name_attribute         PARAMS ((dw_die_ref, const char *));
 static void add_bound_info             PARAMS ((dw_die_ref,
                                                 enum dwarf_attribute, tree));
@@ -3441,14 +3523,15 @@ static void gen_block_die               PARAMS ((tree, dw_die_ref, int));
 static void decls_for_scope            PARAMS ((tree, dw_die_ref, int));
 static int is_redundant_typedef                PARAMS ((tree));
 static void gen_decl_die               PARAMS ((tree, dw_die_ref));
-static unsigned lookup_filename                PARAMS ((const char *));
+static unsigned lookup_filename                PARAMS ((struct file_table *,
+                                                const char *));
+static void init_file_table            PARAMS ((struct file_table *));
 static void add_incomplete_type                PARAMS ((tree));
 static void retry_incomplete_types     PARAMS ((void));
 static void gen_type_die_for_member    PARAMS ((tree, tree, dw_die_ref));
 static void gen_abstract_function      PARAMS ((tree));
 static rtx save_rtx                    PARAMS ((rtx));
 static void splice_child_die           PARAMS ((dw_die_ref, dw_die_ref));
-static void reverse_die_lists          PARAMS ((dw_die_ref));
 
 /* Section names used to hold DWARF debugging information.  */
 #ifndef DEBUG_INFO_SECTION
@@ -3488,7 +3571,7 @@ static void reverse_die_lists             PARAMS ((dw_die_ref));
 #endif
 
 /* Labels we insert at beginning sections we can reference instead of
-   the section names themselves. */
+   the section names themselves.  */
 
 #ifndef TEXT_SECTION_LABEL
 #define TEXT_SECTION_LABEL      "Ltext"
@@ -3503,7 +3586,6 @@ static void reverse_die_lists             PARAMS ((dw_die_ref));
 #define ABBREV_SECTION_LABEL     "Ldebug_abbrev"
 #endif
 
-
 /* Definitions of defaults for formats and names of various special
    (artificial) labels which may be generated within this file (when the -g
    options is used and DWARF_DEBUGGING_INFO is in effect.
@@ -3525,9 +3607,6 @@ static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 #ifndef BSS_END_LABEL
 #define BSS_END_LABEL           "Lebss"
 #endif
-#ifndef INSN_LABEL_FMT
-#define INSN_LABEL_FMT         "LI%u_"
-#endif
 #ifndef BLOCK_BEGIN_LABEL
 #define BLOCK_BEGIN_LABEL      "LBB"
 #endif
@@ -3567,15 +3646,7 @@ static rtx
 save_rtx (orig)
      register rtx orig;
 {
-  if (ggc_p)
-    VARRAY_PUSH_RTX (used_rtx_varray, orig);
-  else
-    {
-      push_obstacks_nochange ();
-      end_temporary_allocation ();
-      orig = copy_rtx (orig);
-      pop_obstacks ();
-    }
+  VARRAY_PUSH_RTX (used_rtx_varray, orig);
 
   return orig;
 }
@@ -3600,7 +3671,7 @@ type_main_variant (type)
 {
   type = TYPE_MAIN_VARIANT (type);
 
-  /* There really should be only one main variant among any group of variants 
+  /* There really should be only one main variant among any group of variants
      of a given type (and all of the MAIN_VARIANT values for all members of
      the group should point to that one type) but sometimes the C front-end
      messes this up for array types, so we work around that bug here.  */
@@ -3736,6 +3807,10 @@ dwarf_tag_name (tag)
       return "DW_TAG_function_template";
     case DW_TAG_class_template:
       return "DW_TAG_class_template";
+    case DW_TAG_GNU_BINCL:
+      return "DW_TAG_GNU_BINCL";
+    case DW_TAG_GNU_EINCL:
+      return "DW_TAG_GNU_EINCL";
     default:
       return "DW_TAG_<unknown>";
     }
@@ -4016,7 +4091,7 @@ decl_ultimate_origin (decl)
   if (DECL_ABSTRACT (decl) && DECL_ABSTRACT_ORIGIN (decl) == decl)
     return NULL_TREE;
 
-#ifdef ENABLE_CHECKING 
+#ifdef ENABLE_CHECKING
   if (DECL_FROM_INLINE (DECL_ORIGIN (decl)))
     /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
        most distant ancestor, this should never happen.  */
@@ -4087,7 +4162,7 @@ decl_class_context (decl)
 }
 \f
 /* Add an attribute/value pair to a DIE.  We build the lists up in reverse
-   addition order, and correct that in add_sibling_attributes.  */
+   addition order, and correct that in reverse_all_dies.  */
 
 static inline void
 add_dwarf_attr (die, attr)
@@ -4134,7 +4209,7 @@ AT_flag (a)
   if (a && AT_class (a) == dw_val_class_flag)
     return a->dw_attr_val.v.val_flag;
 
-  return 0;
+  abort ();
 }
 
 /* Add a signed integer attribute value to a DIE.  */
@@ -4162,7 +4237,7 @@ AT_int (a)
   if (a && AT_class (a) == dw_val_class_const)
     return a->dw_attr_val.v.val_int;
 
-  return 0;
+  abort ();
 }
 
 /* Add an unsigned integer attribute value to a DIE.  */
@@ -4190,7 +4265,7 @@ AT_unsigned (a)
   if (a && AT_class (a) == dw_val_class_unsigned_const)
     return a->dw_attr_val.v.val_unsigned;
 
-  return 0;
+  abort ();
 }
 
 /* Add an unsigned double integer attribute value to a DIE.  */
@@ -4256,7 +4331,7 @@ AT_string (a)
   if (a && AT_class (a) == dw_val_class_str)
     return a->dw_attr_val.v.val_str;
 
-  return NULL;
+  abort ();
 }
 
 /* Add a DIE reference attribute value to a DIE.  */
@@ -4272,7 +4347,8 @@ add_AT_die_ref (die, attr_kind, targ_die)
   attr->dw_attr_next = NULL;
   attr->dw_attr = attr_kind;
   attr->dw_attr_val.val_class = dw_val_class_die_ref;
-  attr->dw_attr_val.v.val_die_ref = targ_die;
+  attr->dw_attr_val.v.val_die_ref.die = targ_die;
+  attr->dw_attr_val.v.val_die_ref.external = 0;
   add_dwarf_attr (die, attr);
 }
 
@@ -4282,9 +4358,32 @@ AT_ref (a)
      register dw_attr_ref a;
 {
   if (a && AT_class (a) == dw_val_class_die_ref)
-    return a->dw_attr_val.v.val_die_ref;
+    return a->dw_attr_val.v.val_die_ref.die;
 
-  return NULL;
+  abort ();
+}
+
+static inline int AT_ref_external PARAMS ((dw_attr_ref));
+static inline int
+AT_ref_external (a)
+     register dw_attr_ref a;
+{
+  if (a && AT_class (a) == dw_val_class_die_ref)
+    return a->dw_attr_val.v.val_die_ref.external;
+
+  return 0;
+}
+
+static inline void set_AT_ref_external PARAMS ((dw_attr_ref, int));
+static inline void
+set_AT_ref_external (a, i)
+     register dw_attr_ref a;
+     int i;
+{
+  if (a && AT_class (a) == dw_val_class_die_ref)
+    a->dw_attr_val.v.val_die_ref.external = i;
+  else
+    abort ();
 }
 
 /* Add an FDE reference attribute value to a DIE.  */
@@ -4329,7 +4428,7 @@ AT_loc (a)
   if (a && AT_class (a) == dw_val_class_loc)
     return a->dw_attr_val.v.val_loc;
 
-  return NULL;
+  abort ();
 }
 
 /* Add an address constant attribute value to a DIE.  */
@@ -4357,7 +4456,7 @@ AT_addr (a)
   if (a && AT_class (a) == dw_val_class_addr)
     return a->dw_attr_val.v.val_addr;
 
-  return NULL;
+  abort ();
 }
 
 /* Add a label identifier attribute value to a DIE.  */
@@ -4392,7 +4491,6 @@ add_AT_lbl_offset (die, attr_kind, label)
   attr->dw_attr_val.val_class = dw_val_class_lbl_offset;
   attr->dw_attr_val.v.val_lbl_id = xstrdup (label);
   add_dwarf_attr (die, attr);
-  
 }
 
 static inline const char *AT_lbl PARAMS ((dw_attr_ref));
@@ -4404,7 +4502,7 @@ AT_lbl (a)
            || AT_class (a) == dw_val_class_lbl_offset))
     return a->dw_attr_val.v.val_lbl_id;
 
-  return NULL;
+  abort ();
 }
 
 /* Get the attribute of type attr_kind.  */
@@ -4416,7 +4514,7 @@ get_AT (die, attr_kind)
 {
   register dw_attr_ref a;
   register dw_die_ref spec = NULL;
-  
+
   if (die != NULL)
     {
       for (a = die->die_attr; a != NULL; a = a->dw_attr_next)
@@ -4446,7 +4544,7 @@ get_AT_low_pc (die)
      register dw_die_ref die;
 {
   register dw_attr_ref a = get_AT (die, DW_AT_low_pc);
-  return AT_lbl (a);
+  return a ? AT_lbl (a) : NULL;
 }
 
 /* Return the "high pc" attribute value, typically associated with
@@ -4459,7 +4557,7 @@ get_AT_hi_pc (die)
      register dw_die_ref die;
 {
   register dw_attr_ref a = get_AT (die, DW_AT_high_pc);
-  return AT_lbl (a);
+  return a ? AT_lbl (a) : NULL;
 }
 
 /* Return the value of the string attribute designated by ATTR_KIND, or
@@ -4471,7 +4569,7 @@ get_AT_string (die, attr_kind)
      register enum dwarf_attribute attr_kind;
 {
   register dw_attr_ref a = get_AT (die, attr_kind);
-  return AT_string (a);
+  return a ? AT_string (a) : NULL;
 }
 
 /* Return the value of the flag attribute designated by ATTR_KIND, or -1
@@ -4483,7 +4581,7 @@ get_AT_flag (die, attr_kind)
      register enum dwarf_attribute attr_kind;
 {
   register dw_attr_ref a = get_AT (die, attr_kind);
-  return AT_flag (a);
+  return a ? AT_flag (a) : 0;
 }
 
 /* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
@@ -4495,7 +4593,7 @@ get_AT_unsigned (die, attr_kind)
      register enum dwarf_attribute attr_kind;
 {
   register dw_attr_ref a = get_AT (die, attr_kind);
-  return AT_unsigned (a);
+  return a ? AT_unsigned (a) : 0;
 }
 
 static inline dw_die_ref
@@ -4504,7 +4602,7 @@ get_AT_ref (die, attr_kind)
      register enum dwarf_attribute attr_kind;
 {
   register dw_attr_ref a = get_AT (die, attr_kind);
-  return AT_ref (a);
+  return a ? AT_ref (a) : NULL;
 }
 
 static inline int
@@ -4514,7 +4612,7 @@ is_c_family ()
 
   return (lang == DW_LANG_C || lang == DW_LANG_C89
          || lang == DW_LANG_C_plus_plus);
-} 
+}
 
 static inline int
 is_fortran ()
@@ -4522,7 +4620,15 @@ is_fortran ()
   register unsigned lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
 
   return (lang == DW_LANG_Fortran77 || lang == DW_LANG_Fortran90);
-} 
+}
+
+static inline int
+is_java ()
+{
+  register unsigned lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
+
+  return (lang == DW_LANG_Java);
+}
 
 /* Free up the memory used by A.  */
 
@@ -4539,12 +4645,16 @@ free_AT (a)
       free (a->dw_attr_val.v.val_str);
       break;
 
+    case dw_val_class_float:
+      free (a->dw_attr_val.v.val_float.array);
+      break;
+
     default:
       break;
     }
 
   free (a);
-}  
+}
 
 /* Remove the specified attribute if present.  */
 
@@ -4598,8 +4708,8 @@ remove_children (die)
       register dw_attr_ref a;
 
       child_die = child_die->die_sib;
-      
-      for (a = tmp_die->die_attr; a != NULL; )
+
+      for (a = tmp_die->die_attr; a != NULL;)
        {
          register dw_attr_ref tmp_a = a;
 
@@ -4612,7 +4722,7 @@ remove_children (die)
 }
 
 /* Add a child DIE below its parent.  We build the lists up in reverse
-   addition order, and correct that in add_sibling_attributes.  */
+   addition order, and correct that in reverse_all_dies.  */
 
 static inline void
 add_child_die (die, child_die)
@@ -4651,7 +4761,7 @@ splice_child_die (parent, child)
       && child->die_parent != get_AT_ref (parent, DW_AT_specification))
     abort ();
 
-  for (p = &(parent->die_child); *p; p = &((*p)->die_sib))
+  for (p = &(child->die_parent->die_child); *p; p = &((*p)->die_sib))
     if (*p == child)
       {
        *p = child->die_sib;
@@ -4678,6 +4788,7 @@ new_die (tag_value, parent_die)
   die->die_parent = NULL;
   die->die_sib = NULL;
   die->die_attr = NULL;
+  die->die_symbol = NULL;
 
   if (parent_die != NULL)
     add_child_die (parent_die, die);
@@ -4748,7 +4859,7 @@ equate_decl_number_to_die (decl, decl_die)
        = (dw_die_ref *) xrealloc (decl_die_table,
                                   sizeof (dw_die_ref) * num_allocated);
 
-      bzero ((char *) &decl_die_table[decl_die_table_allocated],
+      memset ((char *) &decl_die_table[decl_die_table_allocated], 0,
             (num_allocated - decl_die_table_allocated) * sizeof (dw_die_ref));
       decl_die_table_allocated = num_allocated;
     }
@@ -4812,8 +4923,8 @@ print_die (die, outfile)
          break;
        case dw_val_class_long_long:
          fprintf (outfile, "constant (%lu,%lu)",
-                 a->dw_attr_val.v.val_long_long.hi,
-                 a->dw_attr_val.v.val_long_long.low);
+                  a->dw_attr_val.v.val_long_long.hi,
+                  a->dw_attr_val.v.val_long_long.low);
          break;
        case dw_val_class_float:
          fprintf (outfile, "floating-point constant");
@@ -4823,7 +4934,12 @@ print_die (die, outfile)
          break;
        case dw_val_class_die_ref:
          if (AT_ref (a) != NULL)
-           fprintf (outfile, "die -> %lu", AT_ref (a)->die_offset);
+           {
+             if (AT_ref (a)->die_symbol)
+               fprintf (outfile, "die -> label: %s", AT_ref (a)->die_symbol);
+             else
+               fprintf (outfile, "die -> %lu", AT_ref (a)->die_offset);
+           }
          else
            fprintf (outfile, "die -> <null>");
          break;
@@ -4852,6 +4968,8 @@ print_die (die, outfile)
 
       print_indent -= 4;
     }
+  if (print_indent == 0)
+    fprintf (outfile, "\n");
 }
 
 /* Print the contents of the source code line number correspondence table.
@@ -4869,7 +4987,7 @@ print_dwarf_line_table (outfile)
     {
       line_info = &line_info_table[i];
       fprintf (outfile, "%5d: ", i);
-      fprintf (outfile, "%-20s", file_table[line_info->dw_file_num]);
+      fprintf (outfile, "%-20s", line_file_table.table[line_info->dw_file_num]);
       fprintf (outfile, "%6ld", line_info->dw_line_num);
       fprintf (outfile, "\n");
     }
@@ -4926,97 +5044,473 @@ reverse_die_lists (die)
   die->die_child = cp;
 }
 
-/* Traverse the DIE, reverse its lists of attributes and children, and
-   add a sibling attribute if it may have the effect of speeding up
-   access to siblings.  To save some space, avoid generating sibling
-   attributes for DIE's without children.  */
+/* reverse_die_lists only reverses the single die you pass it. Since
+   we used to reverse all dies in add_sibling_attributes, which runs
+   through all the dies, it would reverse all the dies.  Now, however,
+   since we don't call reverse_die_lists in add_sibling_attributes, we
+   need a routine to recursively reverse all the dies. This is that
+   routine.  */
 
 static void
-add_sibling_attributes (die)
+reverse_all_dies (die)
      register dw_die_ref die;
 {
   register dw_die_ref c;
 
   reverse_die_lists (die);
 
-  if (die != comp_unit_die && die->die_sib && die->die_child != NULL)
-    /* Add the sibling link to the front of the attribute list.  */
-    add_AT_die_ref (die, DW_AT_sibling, die->die_sib);
-
-  for (c = die->die_child; c != NULL; c = c->die_sib)
-    add_sibling_attributes (c);
+  for (c = die->die_child; c; c = c->die_sib)
+    reverse_all_dies (c);
 }
 
-/* The format of each DIE (and its attribute value pairs)
-   is encoded in an abbreviation table.  This routine builds the
-   abbreviation table and assigns a unique abbreviation id for
-   each abbreviation entry.  The children of each die are visited
-   recursively.  */
+/* Start a new compilation unit DIE for an include file.  OLD_UNIT is
+   the CU for the enclosing include file, if any.  BINCL_DIE is the
+   DW_TAG_GNU_BINCL DIE that marks the start of the DIEs for this
+   include file.  */
 
-static void
-build_abbrev_table (die)
-     register dw_die_ref die;
+static dw_die_ref
+push_new_compile_unit (old_unit, bincl_die)
+     dw_die_ref old_unit, bincl_die;
 {
-  register unsigned long abbrev_id;
-  register unsigned long n_alloc;
-  register dw_die_ref c;
-  register dw_attr_ref d_attr, a_attr;
-  for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
-    {
-      register dw_die_ref abbrev = abbrev_die_table[abbrev_id];
+  const char *filename = get_AT_string (bincl_die, DW_AT_name);
+  dw_die_ref new_unit = gen_compile_unit_die (filename);
+  new_unit->die_sib = old_unit;
+  return new_unit;
+}
 
-      if (abbrev->die_tag == die->die_tag)
-       {
-         if ((abbrev->die_child != NULL) == (die->die_child != NULL))
-           {
-             a_attr = abbrev->die_attr;
-             d_attr = die->die_attr;
+/* Close an include-file CU and reopen the enclosing one.  */
 
-             while (a_attr != NULL && d_attr != NULL)
-               {
-                 if ((a_attr->dw_attr != d_attr->dw_attr)
-                     || (value_format (a_attr) != value_format (d_attr)))
-                   break;
+static dw_die_ref
+pop_compile_unit (old_unit)
+     dw_die_ref old_unit;
+{
+  dw_die_ref new_unit = old_unit->die_sib;
+  old_unit->die_sib = NULL;
+  return new_unit;
+}
 
-                 a_attr = a_attr->dw_attr_next;
-                 d_attr = d_attr->dw_attr_next;
-               }
+#define PROCESS(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
+#define PROCESS_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO), ctx)
 
-             if (a_attr == NULL && d_attr == NULL)
-               break;
-           }
-       }
-    }
+/* Calculate the checksum of a location expression.  */
 
-  if (abbrev_id >= abbrev_die_table_in_use)
-    {
-      if (abbrev_die_table_in_use >= abbrev_die_table_allocated)
-       {
-         n_alloc = abbrev_die_table_allocated + ABBREV_DIE_TABLE_INCREMENT;
-         abbrev_die_table 
-           = (dw_die_ref *) xrealloc (abbrev_die_table,
-                                      sizeof (dw_die_ref) * n_alloc);
+static inline void
+loc_checksum (loc, ctx)
+     dw_loc_descr_ref loc;
+     struct md5_ctx *ctx;
+{
+  PROCESS (loc->dw_loc_opc);
+  PROCESS (loc->dw_loc_oprnd1);
+  PROCESS (loc->dw_loc_oprnd2);
+}
 
-         bzero ((char *) &abbrev_die_table[abbrev_die_table_allocated],
-                (n_alloc - abbrev_die_table_allocated) * sizeof (dw_die_ref));
-         abbrev_die_table_allocated = n_alloc;
-       }
+/* Calculate the checksum of an attribute.  */
 
-      ++abbrev_die_table_in_use;
-      abbrev_die_table[abbrev_id] = die;
-    }
+static void
+attr_checksum (at, ctx)
+     dw_attr_ref at;
+     struct md5_ctx *ctx;
+{
+  dw_loc_descr_ref loc;
+  rtx r;
 
-  die->die_abbrev = abbrev_id;
-  for (c = die->die_child; c != NULL; c = c->die_sib)
-    build_abbrev_table (c);
-}
-\f
-/* Return the size of a string, including the null byte.
+  PROCESS (at->dw_attr);
 
-   This used to treat backslashes as escapes, and hence they were not included
-   in the count.  However, that conflicts with what ASM_OUTPUT_ASCII does,
-   which treats a backslash as a backslash, escaping it if necessary, and hence
-   we must include them in the count.  */
+  /* We don't care about differences in file numbering.  */
+  if (at->dw_attr == DW_AT_decl_file
+      /* Or that this was compiled with a different compiler snapshot; if
+        the output is the same, that's what matters.  */
+      || at->dw_attr == DW_AT_producer)
+    return;
+
+  switch (AT_class (at))
+    {
+    case dw_val_class_const:
+      PROCESS (at->dw_attr_val.v.val_int);
+      break;
+    case dw_val_class_unsigned_const:
+      PROCESS (at->dw_attr_val.v.val_unsigned);
+      break;
+    case dw_val_class_long_long:
+      PROCESS (at->dw_attr_val.v.val_long_long);
+      break;
+    case dw_val_class_float:
+      PROCESS (at->dw_attr_val.v.val_float);
+      break;
+    case dw_val_class_flag:
+      PROCESS (at->dw_attr_val.v.val_flag);
+      break;
+
+    case dw_val_class_str:
+      PROCESS_STRING (AT_string (at));
+      break;
+    case dw_val_class_addr:
+      r = AT_addr (at);
+      switch (GET_CODE (r))
+       {
+       case SYMBOL_REF:
+         PROCESS_STRING (XSTR (r, 0));
+         break;
+
+       default:
+         abort ();
+       }
+      break;
+
+    case dw_val_class_loc:
+      for (loc = AT_loc (at); loc; loc = loc->dw_loc_next)
+       loc_checksum (loc, ctx);
+      break;
+
+    case dw_val_class_die_ref:
+      if (AT_ref (at)->die_offset)
+       PROCESS (AT_ref (at)->die_offset);
+      /* FIXME else use target die name or something.  */
+
+    case dw_val_class_fde_ref:
+    case dw_val_class_lbl_id:
+    case dw_val_class_lbl_offset:
+
+    default:
+      break;
+    }
+}
+
+/* Calculate the checksum of a DIE.  */
+
+static void
+die_checksum (die, ctx)
+     dw_die_ref die;
+     struct md5_ctx *ctx;
+{
+  dw_die_ref c;
+  dw_attr_ref a;
+
+  PROCESS (die->die_tag);
+
+  for (a = die->die_attr; a; a = a->dw_attr_next)
+    attr_checksum (a, ctx);
+
+  for (c = die->die_child; c; c = c->die_sib)
+    die_checksum (c, ctx);
+}
+
+#undef PROCESS
+#undef PROCESS_STRING
+
+/* The prefix to attach to symbols on DIEs in the current comdat debug
+   info section.  */
+static char *comdat_symbol_id;
+
+/* The index of the current symbol within the current comdat CU.  */
+static unsigned int comdat_symbol_number;
+
+/* Calculate the MD5 checksum of the compilation unit DIE UNIT_DIE and its
+   children, and set comdat_symbol_id accordingly.  */
+
+static void
+compute_section_prefix (unit_die)
+     dw_die_ref unit_die;
+{
+  char *p, *name;
+  int i;
+  unsigned char checksum[16];
+  struct md5_ctx ctx;
+
+  md5_init_ctx (&ctx);
+  die_checksum (unit_die, &ctx);
+  md5_finish_ctx (&ctx, checksum);
+
+  p = file_name_nondirectory (get_AT_string (unit_die, DW_AT_name));
+  name = (char *) alloca (strlen (p) + 64);
+  sprintf (name, "%s.", p);
+
+  clean_symbol_name (name);
+
+  p = name + strlen (name);
+  for (i = 0; i < 4; ++i)
+    {
+      sprintf (p, "%.2x", checksum[i]);
+      p += 2;
+    }
+
+  comdat_symbol_id = unit_die->die_symbol = xstrdup (name);
+  comdat_symbol_number = 0;
+}
+
+/* Returns nonzero iff DIE represents a type, in the sense of TYPE_P.  */
+
+static int
+is_type_die (die)
+     dw_die_ref die;
+{
+  switch (die->die_tag)
+    {
+    case DW_TAG_array_type:
+    case DW_TAG_class_type:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_pointer_type:
+    case DW_TAG_reference_type:
+    case DW_TAG_string_type:
+    case DW_TAG_structure_type:
+    case DW_TAG_subroutine_type:
+    case DW_TAG_union_type:
+    case DW_TAG_ptr_to_member_type:
+    case DW_TAG_set_type:
+    case DW_TAG_subrange_type:
+    case DW_TAG_base_type:
+    case DW_TAG_const_type:
+    case DW_TAG_file_type:
+    case DW_TAG_packed_type:
+    case DW_TAG_volatile_type:
+      return 1;
+    default:
+      return 0;
+    }
+}
+
+/* Returns 1 iff C is the sort of DIE that should go into a COMDAT CU.
+   Basically, we want to choose the bits that are likely to be shared between
+   compilations (types) and leave out the bits that are specific to individual
+   compilations (functions).  */
+
+static int
+is_comdat_die (c)
+     dw_die_ref c;
+{
+#if 1
+  /* I think we want to leave base types and __vtbl_ptr_type in the
+     main CU, as we do for stabs.  The advantage is a greater
+     likelihood of sharing between objects that don't include headers
+     in the same order (and therefore would put the base types in a
+     different comdat).  jason 8/28/00 */
+  if (c->die_tag == DW_TAG_base_type)
+    return 0;
+
+  if (c->die_tag == DW_TAG_pointer_type
+      || c->die_tag == DW_TAG_reference_type
+      || c->die_tag == DW_TAG_const_type
+      || c->die_tag == DW_TAG_volatile_type)
+    {
+      dw_die_ref t = get_AT_ref (c, DW_AT_type);
+      return t ? is_comdat_die (t) : 0;
+    }
+#endif
+
+  return is_type_die (c);
+}
+
+/* Returns 1 iff C is the sort of DIE that might be referred to from another
+   compilation unit.  */
+
+static int
+is_symbol_die (c)
+     dw_die_ref c;
+{
+  if (is_type_die (c))
+    return 1;
+  if (get_AT (c, DW_AT_declaration)
+      && ! get_AT (c, DW_AT_specification))
+    return 1;
+  return 0;
+}
+
+static char *
+gen_internal_sym ()
+{
+  char buf[256];
+  static int label_num;
+  ASM_GENERATE_INTERNAL_LABEL (buf, "LDIE", label_num++);
+  return xstrdup (buf);
+}
+
+/* Assign symbols to all worthy DIEs under DIE.  */
+
+static void
+assign_symbol_names (die)
+     register dw_die_ref die;
+{
+  register dw_die_ref c;
+
+  if (is_symbol_die (die))
+    {
+      if (comdat_symbol_id)
+       {
+         char *p = alloca (strlen (comdat_symbol_id) + 64);
+         sprintf (p, "%s.%s.%x", DIE_LABEL_PREFIX,
+                  comdat_symbol_id, comdat_symbol_number++);
+         die->die_symbol = xstrdup (p);
+       }
+      else
+       die->die_symbol = gen_internal_sym ();
+    }
+
+  for (c = die->die_child; c != NULL; c = c->die_sib)
+    assign_symbol_names (c);
+}
+
+/* Traverse the DIE (which is always comp_unit_die), and set up
+   additional compilation units for each of the include files we see
+   bracketed by BINCL/EINCL.  */
+
+static void
+break_out_includes (die)
+     register dw_die_ref die;
+{
+  dw_die_ref *ptr;
+  register dw_die_ref unit = NULL;
+  limbo_die_node *node;
+
+  for (ptr = &(die->die_child); *ptr; )
+    {
+      register dw_die_ref c = *ptr;
+
+      if (c->die_tag == DW_TAG_GNU_BINCL
+         || c->die_tag == DW_TAG_GNU_EINCL
+         || (unit && is_comdat_die (c)))
+       {
+         /* This DIE is for a secondary CU; remove it from the main one.  */
+         *ptr = c->die_sib;
+
+         if (c->die_tag == DW_TAG_GNU_BINCL)
+           {
+             unit = push_new_compile_unit (unit, c);
+             free_die (c);
+           }
+         else if (c->die_tag == DW_TAG_GNU_EINCL)
+           {
+             unit = pop_compile_unit (unit);
+             free_die (c);
+           }
+         else
+           add_child_die (unit, c);
+       }
+      else
+       {
+         /* Leave this DIE in the main CU.  */
+         ptr = &(c->die_sib);
+         continue;
+       }
+    }
+
+#if 0
+  /* We can only use this in debugging, since the frontend doesn't check
+     to make sure that we leave every include file we enter.  */
+  if (unit != NULL)
+    abort ();
+#endif
+
+  assign_symbol_names (die);
+  for (node = limbo_die_list; node; node = node->next)
+    {
+      compute_section_prefix (node->die);
+      assign_symbol_names (node->die);
+    }
+}
+
+/* Traverse the DIE and add a sibling attribute if it may have the
+   effect of speeding up access to siblings.  To save some space,
+   avoid generating sibling attributes for DIE's without children.  */
+
+static void
+add_sibling_attributes (die)
+     register dw_die_ref die;
+{
+  register dw_die_ref c;
+
+  if (die->die_tag != DW_TAG_compile_unit
+      && die->die_sib && die->die_child != NULL)
+    /* Add the sibling link to the front of the attribute list.  */
+    add_AT_die_ref (die, DW_AT_sibling, die->die_sib);
+
+  for (c = die->die_child; c != NULL; c = c->die_sib)
+    add_sibling_attributes (c);
+}
+
+/* The format of each DIE (and its attribute value pairs)
+   is encoded in an abbreviation table.  This routine builds the
+   abbreviation table and assigns a unique abbreviation id for
+   each abbreviation entry.  The children of each die are visited
+   recursively.  */
+
+static void
+build_abbrev_table (die)
+     register dw_die_ref die;
+{
+  register unsigned long abbrev_id;
+  register unsigned long n_alloc;
+  register dw_die_ref c;
+  register dw_attr_ref d_attr, a_attr;
+
+  /* Scan the DIE references, and mark as external any that refer to
+     DIEs from other CUs (i.e. those which are not marked).  */
+  for (d_attr = die->die_attr; d_attr; d_attr = d_attr->dw_attr_next)
+    {
+      if (AT_class (d_attr) == dw_val_class_die_ref
+         && AT_ref (d_attr)->die_mark == 0)
+       {
+         if (AT_ref (d_attr)->die_symbol == 0)
+           abort ();
+         set_AT_ref_external (d_attr, 1);
+       }
+    }
+
+  for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
+    {
+      register dw_die_ref abbrev = abbrev_die_table[abbrev_id];
+
+      if (abbrev->die_tag == die->die_tag)
+       {
+         if ((abbrev->die_child != NULL) == (die->die_child != NULL))
+           {
+             a_attr = abbrev->die_attr;
+             d_attr = die->die_attr;
+
+             while (a_attr != NULL && d_attr != NULL)
+               {
+                 if ((a_attr->dw_attr != d_attr->dw_attr)
+                     || (value_format (a_attr) != value_format (d_attr)))
+                   break;
+
+                 a_attr = a_attr->dw_attr_next;
+                 d_attr = d_attr->dw_attr_next;
+               }
+
+             if (a_attr == NULL && d_attr == NULL)
+               break;
+           }
+       }
+    }
+
+  if (abbrev_id >= abbrev_die_table_in_use)
+    {
+      if (abbrev_die_table_in_use >= abbrev_die_table_allocated)
+       {
+         n_alloc = abbrev_die_table_allocated + ABBREV_DIE_TABLE_INCREMENT;
+         abbrev_die_table
+           = (dw_die_ref *) xrealloc (abbrev_die_table,
+                                      sizeof (dw_die_ref) * n_alloc);
+
+         memset ((char *) &abbrev_die_table[abbrev_die_table_allocated], 0,
+                (n_alloc - abbrev_die_table_allocated) * sizeof (dw_die_ref));
+         abbrev_die_table_allocated = n_alloc;
+       }
+
+      ++abbrev_die_table_in_use;
+      abbrev_die_table[abbrev_id] = die;
+    }
+
+  die->die_abbrev = abbrev_id;
+  for (c = die->die_child; c != NULL; c = c->die_sib)
+    build_abbrev_table (c);
+}
+\f
+/* Return the size of a string, including the null byte.
+
+   This used to treat backslashes as escapes, and hence they were not included
+   in the count.  However, that conflicts with what ASM_OUTPUT_ASCII does,
+   which treats a backslash as a backslash, escaping it if necessary, and hence
+   we must include them in the count.  */
 
 static unsigned long
 size_of_string (str)
@@ -5131,6 +5625,33 @@ calc_die_sizes (die)
     next_die_offset += 1;
 }
 
+/* Set the marks for a die and its children.  We do this so
+   that we know whether or not a reference needs to use FORM_ref_addr; only
+   DIEs in the same CU will be marked.  We used to clear out the offset
+   and use that as the flag, but ran into ordering problems.  */
+
+static void
+mark_dies (die)
+     dw_die_ref die;
+{
+  register dw_die_ref c;
+  die->die_mark = 1;
+  for (c = die->die_child; c; c = c->die_sib)
+    mark_dies (c);
+}
+
+/* Clear the marks for a die and its children.  */
+
+static void
+unmark_dies (die)
+     dw_die_ref die;
+{
+  register dw_die_ref c;
+  die->die_mark = 0;
+  for (c = die->die_child; c; c = c->die_sib)
+    unmark_dies (c);
+}
+
 /* Return the size of the line information prolog generated for the
    compilation unit.  */
 
@@ -5150,10 +5671,10 @@ size_of_line_prolog ()
      null byte used to terminate the table.  */
   size += 1;
 
-  for (ft_index = 1; ft_index < file_table_in_use; ++ft_index)
+  for (ft_index = 1; ft_index < decl_file_table.in_use; ++ft_index)
     {
       /* File name entry.  */
-      size += size_of_string (file_table[ft_index]);
+      size += size_of_string (decl_file_table.table[ft_index]);
 
       /* Include directory index.  */
       size += size_of_uleb128 (0);
@@ -5251,7 +5772,10 @@ value_format (a)
     case dw_val_class_flag:
       return DW_FORM_flag;
     case dw_val_class_die_ref:
-      return DW_FORM_ref;
+      if (AT_ref_external (a))
+       return DW_FORM_ref_addr;
+      else
+       return DW_FORM_ref;
     case dw_val_class_fde_ref:
       return DW_FORM_data;
     case dw_val_class_lbl_id:
@@ -5304,7 +5828,7 @@ output_abbrev_section ()
                 dwarf_tag_name (abbrev->die_tag));
 
       fputc ('\n', asm_out_file);
-      fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP,
+      fprintf (asm_out_file, "%s0x%x", ASM_BYTE_OP,
               abbrev->die_child != NULL ? DW_children_yes : DW_children_no);
 
       if (flag_debug_asm)
@@ -5327,11 +5851,44 @@ output_abbrev_section ()
          output_value_format (a_attr);
        }
 
-      fprintf (asm_out_file, "\t%s\t0,0\n", ASM_BYTE_OP);
+      fprintf (asm_out_file, "%s0,0\n", ASM_BYTE_OP);
     }
 
   /* Terminate the table.  */
-  fprintf (asm_out_file, "\t%s\t0\n", ASM_BYTE_OP);
+  fprintf (asm_out_file, "%s0\n", ASM_BYTE_OP);
+}
+
+/* Output a symbol we can use to refer to this DIE from another CU.  */
+
+static inline void
+output_die_symbol (die)
+     register dw_die_ref die;
+{
+  char *sym = die->die_symbol;
+
+  if (sym == 0)
+    return;
+
+  if (strncmp (sym, DIE_LABEL_PREFIX, sizeof (DIE_LABEL_PREFIX) - 1) == 0)
+    /* We make these global, not weak; if the target doesn't support
+       .linkonce, it doesn't support combining the sections, so debugging
+       will break.  */
+    ASM_GLOBALIZE_LABEL (asm_out_file, sym);
+  ASM_OUTPUT_LABEL (asm_out_file, sym);
+}
+
+/* Output a symbolic (i.e. FORM_ref_addr) reference to TARGET_DIE.  */
+
+static inline void
+output_symbolic_ref (target_die)
+     dw_die_ref target_die;
+{
+  char *sym = target_die->die_symbol;
+
+  if (sym == 0)
+    abort ();
+
+  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, sym);
 }
 
 /* Output the DIE and its attributes.  Called recursively to generate
@@ -5345,6 +5902,11 @@ output_die (die)
   register dw_die_ref c;
   register unsigned long size;
 
+  /* If someone in another CU might refer to us, set up a symbol for
+     them to point to.  */
+  if (die->die_symbol)
+    output_die_symbol (die);
+
   output_uleb128 (die->die_abbrev);
   if (flag_debug_asm)
     fprintf (asm_out_file, " (DIE (0x%lx) %s)",
@@ -5416,7 +5978,7 @@ output_die (die)
          ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 8);
          if (flag_debug_asm)
            fprintf (asm_out_file, "\t%s %s",
-                  ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
+                    ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
 
          fputc ('\n', asm_out_file);
          ASM_OUTPUT_DWARF_CONST_DOUBLE (asm_out_file,
@@ -5426,7 +5988,7 @@ output_die (die)
          if (flag_debug_asm)
            fprintf (asm_out_file,
                     "\t%s long long constant", ASM_COMMENT_START);
-         
+
          fputc ('\n', asm_out_file);
          break;
 
@@ -5450,7 +6012,7 @@ output_die (die)
 
                fputc ('\n', asm_out_file);
              }
-         break;
+           break;
          }
 
        case dw_val_class_flag:
@@ -5458,7 +6020,10 @@ output_die (die)
          break;
 
        case dw_val_class_die_ref:
-         ASM_OUTPUT_DWARF_DATA (asm_out_file, AT_ref (a)->die_offset);
+         if (AT_ref_external (a))
+           output_symbolic_ref (AT_ref (a));
+         else
+           ASM_OUTPUT_DWARF_DATA (asm_out_file, AT_ref (a)->die_offset);
          break;
 
        case dw_val_class_fde_ref:
@@ -5508,7 +6073,7 @@ output_die (die)
 
   if (die->die_child != NULL)
     {
-      /* Add null byte to terminate sibling list. */
+      /* Add null byte to terminate sibling list.  */
       ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
       if (flag_debug_asm)
        fprintf (asm_out_file, "\t%s end of children of DIE 0x%lx",
@@ -5548,6 +6113,48 @@ output_compilation_unit_header ()
   fputc ('\n', asm_out_file);
 }
 
+/* Output the compilation unit DIE and its children.  */
+
+static void
+output_comp_unit (die)
+     dw_die_ref die;
+{
+  const char *secname;
+
+  if (die->die_child == 0)
+    return;
+
+  /* Mark all the DIEs in this CU so we know which get local refs.  */
+  mark_dies (die);
+
+  build_abbrev_table (die);
+
+  /* Initialize the beginning DIE offset - and calculate sizes/offsets.   */
+  next_die_offset = DWARF_COMPILE_UNIT_HEADER_SIZE;
+  calc_die_sizes (die);
+
+  if (die->die_symbol)
+    {
+      char *tmp = (char *) alloca (strlen (die->die_symbol) + 24);
+      sprintf (tmp, ".gnu.linkonce.wi.%s", die->die_symbol);
+      secname = tmp;
+      die->die_symbol = NULL;
+    }
+  else
+    secname = (const char *) DEBUG_INFO_SECTION;
+
+  /* Output debugging information.  */
+  fputc ('\n', asm_out_file);
+  ASM_OUTPUT_SECTION (asm_out_file, secname);
+  output_compilation_unit_header ();
+  output_die (die);
+
+  /* Leave the marks on the main CU, so we can check them in
+     output_pubnames.  */
+  if (die->die_symbol)
+    unmark_dies (die);
+}
+
 /* The DWARF2 pubname for a nested thingy looks like "A::f".  The output
    of decl_printable_name for C++ looks like "A::f(int)".  Let's drop the
    argument list, and maybe the scope.  */
@@ -5623,6 +6230,10 @@ output_pubnames ()
     {
       register pubname_ref pub = &pubname_table[i];
 
+      /* We shouldn't see pubnames for DIEs outside of the main CU.  */
+      if (pub->die->die_mark == 0)
+       abort ();
+
       ASM_OUTPUT_DWARF_DATA (asm_out_file, pub->die->die_offset);
       if (flag_debug_asm)
        fprintf (asm_out_file, "\t%s DIE offset", ASM_COMMENT_START);
@@ -5714,10 +6325,10 @@ output_aranges ()
          for any pointer size.  */
       ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
       for (i = 2; i < DWARF_ARANGES_PAD_SIZE; i += 2)
-        fprintf (asm_out_file, ",0");
+       fprintf (asm_out_file, ",0");
       if (flag_debug_asm)
-        fprintf (asm_out_file, "\t%s Pad to %d byte boundary",
-                 ASM_COMMENT_START, 2 * DWARF2_ADDR_SIZE);
+       fprintf (asm_out_file, "\t%s Pad to %d byte boundary",
+                ASM_COMMENT_START, 2 * DWARF2_ADDR_SIZE);
     }
 
   fputc ('\n', asm_out_file);
@@ -5736,6 +6347,10 @@ output_aranges ()
     {
       dw_die_ref die = arange_table[i];
 
+      /* We shouldn't see aranges for DIEs outside of the main CU.  */
+      if (die->die_mark == 0)
+       abort ();
+
       if (die->die_tag == DW_TAG_subprogram)
        ASM_OUTPUT_DWARF_ADDR (asm_out_file, get_AT_low_pc (die));
       else
@@ -5781,6 +6396,314 @@ output_aranges ()
   fputc ('\n', asm_out_file);
 }
 
+
+/* Data structure containing information about input files.  */
+struct file_info
+{
+  char *path;          /* Complete file name.  */
+  char *fname;         /* File name part.  */
+  int length;          /* Length of entire string.  */
+  int file_idx;                /* Index in input file table.  */
+  int dir_idx;         /* Index in directory table.  */
+};
+
+/* Data structure containing information about directories with source
+   files.  */
+struct dir_info
+{
+  char *path;          /* Path including directory name.  */
+  int length;          /* Path length.  */
+  int prefix;          /* Index of directory entry which is a prefix.  */
+  int nbytes;          /* Total number of bytes in all file names excluding
+                          paths.  */
+  int count;           /* Number of files in this directory.  */
+  int dir_idx;         /* Index of directory used as base.  */
+  int used;            /* Used in the end?  */
+};
+
+/* Callback function for file_info comparison.  We sort by looking at
+   the directories in the path.  */
+static int
+file_info_cmp (p1, p2)
+     const void *p1;
+     const void *p2;
+{
+  const struct file_info *s1 = p1;
+  const struct file_info *s2 = p2;
+  unsigned char *cp1;
+  unsigned char *cp2;
+
+  /* Take care of file names without directories.  */
+  if (s1->path == s1->fname)
+    return -1;
+  else if (s2->path == s2->fname)
+    return 1;
+
+  cp1 = (unsigned char *) s1->path;
+  cp2 = (unsigned char *) s2->path;
+
+  while (1)
+    {
+      ++cp1;
+      ++cp2;
+      /* Reached the end of the first path?  */
+      if (cp1 == (unsigned char *) s1->fname)
+       /* It doesn't really matter in which order files from the
+          same directory are sorted in.  Therefore don't test for
+          the second path reaching the end.  */
+       return -1;
+      else if (cp2 == (unsigned char *) s2->fname)
+       return 1;
+
+      /* Character of current path component the same?  */
+      if (*cp1 != *cp2)
+       return *cp1 - *cp2;
+    }
+}
+
+/* Output the directory table and the file name table.  We try to minimize
+   the total amount of memory needed.  A heuristic is used to avoid large
+   slowdowns with many input files.  */
+static void
+output_file_names ()
+{
+  struct file_info *files;
+  struct dir_info *dirs;
+  int *saved;
+  int *savehere;
+  int *backmap;
+  int ndirs;
+  int idx_offset;
+  int i;
+  int idx;
+
+  /* Allocate the various arrays we need.  */
+  files = (struct file_info *) alloca (line_file_table.in_use
+                                      * sizeof (struct file_info));
+  dirs = (struct dir_info *) alloca (line_file_table.in_use
+                                    * sizeof (struct dir_info));
+
+  /* Sort the file names.  */
+   for (i = 1; i < (int) line_file_table.in_use; ++i)
+    {
+      char *f;
+
+      /* Skip all leading "./".  */
+      f = line_file_table.table[i];
+      while (f[0] == '.' && f[1] == '/')
+       f += 2;
+
+      /* Create a new array entry.  */
+      files[i].path = f;
+      files[i].length = strlen (f);
+      files[i].file_idx = i;
+
+      /* Search for the file name part.  */
+      f = strrchr (f, '/');
+      files[i].fname = f == NULL ? files[i].path : f + 1;
+    }
+  qsort (files + 1, line_file_table.in_use - 1, sizeof (files[0]),
+        file_info_cmp);
+
+  /* Find all the different directories used.  */
+  dirs[0].path = files[1].path;
+  dirs[0].length = files[1].fname - files[1].path;
+  dirs[0].prefix = -1;
+  dirs[0].nbytes = files[1].length - dirs[1].length + 1;
+  dirs[0].count = 1;
+  dirs[0].dir_idx = 0;
+  dirs[0].used = 0;
+  files[1].dir_idx = 0;
+  ndirs = 1;
+
+  for (i = 2; i < (int) line_file_table.in_use; ++i)
+    if (files[i].fname - files[i].path == dirs[ndirs - 1].length
+       && memcmp (dirs[ndirs - 1].path, files[i].path,
+                  dirs[ndirs - 1].length) == 0)
+      {
+       /* Same directory as last entry.  */
+       files[i].dir_idx = ndirs - 1;
+       dirs[ndirs - 1].nbytes += files[i].length - dirs[ndirs - 1].length + 1;
+       ++dirs[ndirs - 1].count;
+      }
+    else
+      {
+       int j;
+
+       /* This is a new directory.  */
+       dirs[ndirs].path = files[i].path;
+       dirs[ndirs].length = files[i].fname - files[i].path;
+       dirs[ndirs].nbytes = files[i].length - dirs[i].length + 1;
+       dirs[ndirs].count = 1;
+       dirs[ndirs].dir_idx = ndirs;
+       dirs[ndirs].used = 0;
+       files[i].dir_idx = ndirs;
+
+       /* Search for a prefix.  */
+       dirs[ndirs].prefix = -1;
+       for (j = 0; j < ndirs; ++j)
+         if (dirs[j].length < dirs[ndirs].length
+             && dirs[j].length != 0
+             && memcmp (dirs[j].path, dirs[ndirs].path, dirs[j].length) == 0)
+           dirs[ndirs].prefix = j;
+
+       ++ndirs;
+      }
+
+  /* Now to the actual work.  We have to find a subset of the
+     directories which allow expressing the file name using references
+     to the directory table with the least amount of characters.  We
+     do not do an exhaustive search where we would have to check out
+     every combination of every single possible prefix.  Instead we
+     use a heuristic which provides nearly optimal results in most
+     cases and never is much off.  */
+  saved = (int *) alloca (ndirs * sizeof (int));
+  savehere = (int *) alloca (ndirs * sizeof (int));
+
+  memset (saved, '\0', ndirs * sizeof (saved[0]));
+  for (i = 0; i < ndirs; ++i)
+    {
+      int j;
+      int total;
+
+      /* We can always safe some space for the current directory.  But
+        this does not mean it will be enough to justify adding the
+        directory.  */
+      savehere[i] = dirs[i].length;
+      total = (savehere[i] - saved[i]) * dirs[i].count;
+
+      for (j = i + 1; j < ndirs; ++j)
+       {
+         savehere[j] = 0;
+
+         if (saved[j] < dirs[i].length)
+           {
+             /* Determine whether the dirs[i] path is a prefix of the
+                dirs[j] path.  */
+             int k;
+
+              k = dirs[j].prefix;
+              while (k != -1 && k != i)
+                k = dirs[k].prefix;
+
+              if (k == i)
+                {
+                  /* Yes it is.  We can possibly safe some memory but
+                     writing the filenames in dirs[j] relative to
+                     dirs[i].  */
+                  savehere[j] = dirs[i].length;
+                  total += (savehere[j] - saved[j]) * dirs[j].count;
+                }
+           }
+       }
+
+      /* Check whether we can safe enough to justify adding the dirs[i]
+        directory.  */
+      if (total > dirs[i].length + 1)
+       {
+          /* It's worthwhile adding.  */
+          for (j = i; j < ndirs; ++j)
+           if (savehere[j] > 0)
+             {
+               /* Remember how much we saved for this directory so far.  */
+               saved[j] = savehere[j];
+
+               /* Remember the prefix directory.  */
+               dirs[j].dir_idx = i;
+             }
+       }
+    }
+
+  /* We have to emit them in the order they appear in the line_file_table
+     array since the index is used in the debug info generation.  To
+     do this efficiently we generate a back-mapping of the indices
+     first.  */
+  backmap = (int *) alloca (line_file_table.in_use * sizeof (int));
+  for (i = 1; i < (int) line_file_table.in_use; ++i)
+    {
+      backmap[files[i].file_idx] = i;
+      /* Mark this directory as used.  */
+      dirs[dirs[files[i].dir_idx].dir_idx].used = 1;
+    }
+
+  /* That was it.  We are ready to emit the information.  First the
+     directory name table.  Here we have to make sure that the first
+     actually emitted directory name has the index one.  Zero is
+     reserved for the current working directory.  Make sure we do not
+     confuse these indices with the one for the constructed table
+     (even though most of the time they are identical).  */
+  idx = 1;
+  idx_offset = dirs[0].path[0] == '/' ? 1 : 0;
+  for (i = 1 - idx_offset; i < ndirs; ++i)
+    if (dirs[i].used != 0)
+      {
+       dirs[i].used = idx++;
+
+       if (flag_debug_asm)
+         {
+           ASM_OUTPUT_DWARF_NSTRING (asm_out_file,
+                                     dirs[i].path, dirs[i].length - 1);
+           fprintf (asm_out_file, "%s Directory Entry: 0x%x\n",
+                    ASM_COMMENT_START, dirs[i].used);
+         }
+       else
+         {
+           ASM_OUTPUT_ASCII (asm_out_file, dirs[i].path, dirs[i].length - 1);
+           ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
+           fputc ('\n', asm_out_file);
+         }
+      }
+  /* Correct the index for the current working directory entry if it
+     exists.  */
+  if (idx_offset == 0)
+    dirs[0].used = 0;
+  /* Terminate the directory name array.  */
+  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
+  if (flag_debug_asm)
+    fprintf (asm_out_file, "\t%s End directory table", ASM_COMMENT_START);
+  fputc ('\n', asm_out_file);
+
+  /* Now write all the file names.  */
+  for (i = 1; i < (int) line_file_table.in_use; ++i)
+    {
+      int file_idx = backmap[i];
+      int dir_idx = dirs[files[file_idx].dir_idx].dir_idx;
+
+      if (flag_debug_asm)
+       {
+         ASM_OUTPUT_DWARF_STRING (asm_out_file,
+                                  files[file_idx].path
+                                  + dirs[dir_idx].length);
+         fprintf (asm_out_file, "%s File Entry: 0x%x\n",
+                  ASM_COMMENT_START, i);
+       }
+      else
+       ASM_OUTPUT_ASCII (asm_out_file,
+                         files[file_idx].path + dirs[dir_idx].length,
+                         (files[file_idx].length
+                          - dirs[dir_idx].length) + 1);
+
+      /* Include directory index.  */
+      output_uleb128 (dirs[dir_idx].used);
+      fputc ('\n', asm_out_file);
+
+      /* Modification time.  */
+      output_uleb128 (0);
+      fputc ('\n', asm_out_file);
+
+      /* File length in bytes.  */
+      output_uleb128 (0);
+      fputc ('\n', asm_out_file);
+    }
+
+  /* Terminate the file name table */
+  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
+  if (flag_debug_asm)
+    fprintf (asm_out_file, "\t%s End file name table", ASM_COMMENT_START);
+  fputc ('\n', asm_out_file);
+}
+
+
 /* Output the source line number correspondence information.  This
    information goes into the .debug_line section.  */
 
@@ -5791,7 +6714,6 @@ output_line_info ()
   char prev_line_label[MAX_ARTIFICIAL_LABEL_BYTES];
   register unsigned opc;
   register unsigned n_op_args;
-  register unsigned long ft_index;
   register unsigned long lt_index;
   register unsigned long current_line;
   register long line_offset;
@@ -5828,19 +6750,19 @@ output_line_info ()
             ASM_COMMENT_START);
 
   fputc ('\n', asm_out_file);
-  fprintf (asm_out_file, "\t%s\t%d", ASM_BYTE_OP, DWARF_LINE_BASE);
+  fprintf (asm_out_file, "%s%d", ASM_BYTE_OP, DWARF_LINE_BASE);
   if (flag_debug_asm)
     fprintf (asm_out_file, "\t%s Line Base Value (Special Opcodes)",
             ASM_COMMENT_START);
 
   fputc ('\n', asm_out_file);
-  fprintf (asm_out_file, "\t%s\t%u", ASM_BYTE_OP, DWARF_LINE_RANGE);
+  fprintf (asm_out_file, "%s%u", ASM_BYTE_OP, DWARF_LINE_RANGE);
   if (flag_debug_asm)
     fprintf (asm_out_file, "\t%s Line Range Value (Special Opcodes)",
             ASM_COMMENT_START);
 
   fputc ('\n', asm_out_file);
-  fprintf (asm_out_file, "\t%s\t%u", ASM_BYTE_OP, DWARF_LINE_OPCODE_BASE);
+  fprintf (asm_out_file, "%s%u", ASM_BYTE_OP, DWARF_LINE_OPCODE_BASE);
   if (flag_debug_asm)
     fprintf (asm_out_file, "\t%s Special Opcode Base", ASM_COMMENT_START);
 
@@ -5867,48 +6789,8 @@ output_line_info ()
       fputc ('\n', asm_out_file);
     }
 
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "%s Include Directory Table\n", ASM_COMMENT_START);
-
-  /* Include directory table is empty, at present */
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-  fputc ('\n', asm_out_file);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "%s File Name Table\n", ASM_COMMENT_START);
-
-  for (ft_index = 1; ft_index < file_table_in_use; ++ft_index)
-    {
-      if (flag_debug_asm)
-       {
-         ASM_OUTPUT_DWARF_STRING (asm_out_file, file_table[ft_index]);
-         fprintf (asm_out_file, "%s File Entry: 0x%lx",
-                  ASM_COMMENT_START, ft_index);
-       }
-      else
-       {
-         ASM_OUTPUT_ASCII (asm_out_file,
-                           file_table[ft_index],
-                           (int) strlen (file_table[ft_index]) + 1);
-       }
-
-      fputc ('\n', asm_out_file);
-
-      /* Include directory index */
-      output_uleb128 (0);
-      fputc ('\n', asm_out_file);
-
-      /* Modification time */
-      output_uleb128 (0);
-      fputc ('\n', asm_out_file);
-
-      /* File length in bytes */
-      output_uleb128 (0);
-      fputc ('\n', asm_out_file);
-    }
-
-  /* Terminate the file name table */
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-  fputc ('\n', asm_out_file);
+  /* Write out the information about the files we use.  */
+  output_file_names ();
 
   /* We used to set the address register to the first location in the text
      section here, but that didn't accomplish anything since we already
@@ -5989,7 +6871,8 @@ output_line_info ()
          fputc ('\n', asm_out_file);
          output_uleb128 (current_file);
          if (flag_debug_asm)
-           fprintf (asm_out_file, " (\"%s\")", file_table[current_file]);
+           fprintf (asm_out_file, " (\"%s\")",
+                    line_file_table.table[current_file]);
 
          fputc ('\n', asm_out_file);
        }
@@ -6081,7 +6964,7 @@ output_line_info ()
   function = 0;
   current_file = 1;
   current_line = 1;
-  for (lt_index = 0; lt_index < separate_line_info_table_in_use; )
+  for (lt_index = 0; lt_index < separate_line_info_table_in_use;)
     {
       register dw_separate_line_info_ref line_info
        = &separate_line_info_table[lt_index];
@@ -6161,7 +7044,8 @@ output_line_info ()
          fputc ('\n', asm_out_file);
          output_uleb128 (current_file);
          if (flag_debug_asm)
-           fprintf (asm_out_file, " (\"%s\")", file_table[current_file]);
+           fprintf (asm_out_file, " (\"%s\")",
+                    line_file_table.table[current_file]);
 
          fputc ('\n', asm_out_file);
        }
@@ -6301,7 +7185,7 @@ base_type_die (type)
     case INTEGER_TYPE:
       /* Carefully distinguish the C character types, without messing
          up if the language is not C. Note that we check only for the names
-         that contain spaces; other names might occur by coincidence in other 
+         that contain spaces; other names might occur by coincidence in other
          languages.  */
       if (! (TYPE_PRECISION (type) == CHAR_TYPE_SIZE
             && (type == char_type_node
@@ -6314,7 +7198,7 @@ base_type_die (type)
            encoding = DW_ATE_signed;
          break;
        }
-      /* else fall through */
+      /* else fall through */
 
     case CHAR_TYPE:
       /* GNU Pascal/Ada CHAR type.  Not used in C.  */
@@ -6451,7 +7335,7 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
       if (mod_type_die)
        return mod_type_die;
 
-      /* Handle C typedef types. */
+      /* Handle C typedef types.  */
       if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
          && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
        {
@@ -6475,7 +7359,8 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
        }
 
       if (mod_type_die)
-       /* OK */;
+       /* OK.  */
+       ;
       else if (is_const_type)
        {
          mod_type_die = new_die (DW_TAG_const_type, comp_unit_die);
@@ -6501,7 +7386,7 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
          add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
 #if 0
          add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
-#endif 
+#endif
          item_type = TREE_TYPE (type);
        }
       else if (is_base_type (type))
@@ -6584,6 +7469,46 @@ reg_loc_descriptor (rtl)
   return loc_result;
 }
 
+/* Return a location descriptor that designates a constant.  */
+
+static dw_loc_descr_ref
+int_loc_descriptor (i)
+     HOST_WIDE_INT i;
+{
+  enum dwarf_location_atom op;
+
+  /* Pick the smallest representation of a constant, rather than just
+     defaulting to the LEB encoding.  */
+  if (i >= 0)
+    {
+      if (i <= 31)
+       op = DW_OP_lit0 + i;
+      else if (i <= 0xff)
+       op = DW_OP_const1u;
+      else if (i <= 0xffff)
+       op = DW_OP_const2u;
+      else if (HOST_BITS_PER_WIDE_INT == 32
+              || i <= 0xffffffff)
+       op = DW_OP_const4u;
+      else
+       op = DW_OP_constu;
+    }
+  else
+    {
+      if (i >= -0x80)
+       op = DW_OP_const1s;
+      else if (i >= -0x8000)
+       op = DW_OP_const2s;
+      else if (HOST_BITS_PER_WIDE_INT == 32
+              || i >= -0x80000000)
+       op = DW_OP_const4s;
+      else
+       op = DW_OP_consts;
+    }
+
+  return new_loc_descr (op, i, 0);
+}
+
 /* Return a location descriptor that designates a base+offset location.  */
 
 static dw_loc_descr_ref
@@ -6639,7 +7564,7 @@ mem_loc_descriptor (rtl, mode)
      enum machine_mode mode;
 {
   dw_loc_descr_ref mem_loc_result = NULL;
-  /* Note that for a dynamically sized array, the location we will generate a 
+  /* Note that for a dynamically sized array, the location we will generate a
      description of here will be the lowest numbered location which is
      actually within the array.  That's *not* necessarily the same as the
      zeroth element of the array.  */
@@ -6655,7 +7580,7 @@ mem_loc_descriptor (rtl, mode)
       /* POST_INC and POST_DEC can be handled just like a SUBREG.  So we
         just fall into the SUBREG code.  */
 
-      /* ... fall through ... */
+      /* Fall through.  */
 
     case SUBREG:
       /* The case of a subreg may arise when we have a local (register)
@@ -6665,12 +7590,12 @@ mem_loc_descriptor (rtl, mode)
          contains the given subreg.  */
       rtl = XEXP (rtl, 0);
 
-      /* ... fall through ... */
+      /* Fall through.  */
 
     case REG:
       /* Whenever a register number forms a part of the description of the
          method for calculating the (dynamic) address of a memory resident
-         object, DWARF rules require the register number be referred to as 
+         object, DWARF rules require the register number be referred to as
          a "base register".  This distinction is not based in any way upon
          what category of register the hardware believes the given register
          belongs to.  This is strictly DWARF terminology we're dealing with
@@ -6684,13 +7609,23 @@ mem_loc_descriptor (rtl, mode)
       mem_loc_result = based_loc_descr (reg_number (rtl), 0);
       break;
 
-    case MEM:
-      mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode);
-      add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
+    case MEM:
+      {
+       dw_loc_descr_ref deref;
+
+       mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
+
+       if (GET_MODE_SIZE (mode) == DWARF2_ADDR_SIZE)
+         deref = new_loc_descr (DW_OP_deref, 0, 0);
+       else
+         deref = new_loc_descr (DW_OP_deref_size, GET_MODE_SIZE (mode), 0);
+
+       add_loc_descr (&mem_loc_result, deref);
+      }
       break;
 
-     case LABEL_REF:
-       /* Some ports can transform a symbol ref into a label ref, because
+    case LABEL_REF:
+      /* Some ports can transform a symbol ref into a label ref, because
         the symbol ref is too far away and has to be dumped into a constant
         pool.  */
     case CONST:
@@ -6706,10 +7641,10 @@ mem_loc_descriptor (rtl, mode)
         below.  */
       rtl = gen_rtx_PLUS (word_mode, XEXP (rtl, 0),
                          GEN_INT (GET_CODE (rtl) == PRE_INC
-                                  ? GET_MODE_UNIT_SIZE (mode) 
-                                  : - GET_MODE_UNIT_SIZE (mode)));
-                         
-      /* ... fall through ... */
+                                  ? GET_MODE_UNIT_SIZE (mode)
+                                  : -GET_MODE_UNIT_SIZE (mode)));
+
+      /* Fall through.  */
 
     case PLUS:
       if (is_based_loc (rtl))
@@ -6717,24 +7652,37 @@ mem_loc_descriptor (rtl, mode)
                                          INTVAL (XEXP (rtl, 1)));
       else
        {
-         add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 0),
-                                                             mode));
-         add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 1),
-                                                             mode));
-         add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_plus, 0, 0));
+         mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode);
+
+         if (GET_CODE (XEXP (rtl, 1)) == CONST_INT
+             && INTVAL (XEXP (rtl, 1)) >= 0)
+           {
+             add_loc_descr (&mem_loc_result,
+                            new_loc_descr (DW_OP_plus_uconst,
+                                           INTVAL (XEXP (rtl, 1)), 0));
+           }
+         else
+           {
+             add_loc_descr (&mem_loc_result,
+                            mem_loc_descriptor (XEXP (rtl, 1), mode));
+             add_loc_descr (&mem_loc_result,
+                            new_loc_descr (DW_OP_plus, 0, 0));
+           }
        }
       break;
 
     case MULT:
       /* If a pseudo-reg is optimized away, it is possible for it to
         be replaced with a MEM containing a multiply.  */
-      add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 0), mode));
-      add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 1), mode));
+      add_loc_descr (&mem_loc_result,
+                    mem_loc_descriptor (XEXP (rtl, 0), mode));
+      add_loc_descr (&mem_loc_result,
+                    mem_loc_descriptor (XEXP (rtl, 1), mode));
       add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_mul, 0, 0));
       break;
 
     case CONST_INT:
-      mem_loc_result = new_loc_descr (DW_OP_constu, INTVAL (rtl), 0);
+      mem_loc_result = int_loc_descriptor (INTVAL (rtl));
       break;
 
     default:
@@ -6789,7 +7737,7 @@ loc_descriptor (rtl)
          contains the given subreg.  */
       rtl = XEXP (rtl, 0);
 
-      /* ... fall through ... */
+      /* Fall through.  */
 
     case REG:
       loc_result = reg_loc_descriptor (rtl);
@@ -6810,6 +7758,262 @@ loc_descriptor (rtl)
   return loc_result;
 }
 
+/* Similar, but generate the descriptor from trees instead of rtl.
+   This comes up particularly with variable length arrays.  */
+
+static dw_loc_descr_ref
+loc_descriptor_from_tree (loc, addressp)
+     tree loc;
+     int addressp;
+{
+  dw_loc_descr_ref ret = NULL;
+  int indirect_size = 0;
+  int unsignedp = TREE_UNSIGNED (TREE_TYPE (loc));
+  enum dwarf_location_atom op;
+
+  /* ??? Most of the time we do not take proper care for sign/zero
+     extending the values properly.  Hopefully this won't be a real
+     problem...  */
+
+  switch (TREE_CODE (loc))
+    {
+    case ERROR_MARK:
+      break;
+
+    case VAR_DECL:
+    case PARM_DECL:
+      {
+       rtx rtl = rtl_for_decl_location (loc);
+       enum machine_mode mode = DECL_MODE (loc);
+
+       if (rtl == NULL_RTX)
+         break;
+       else if (CONSTANT_P (rtl))
+         {
+           ret = new_loc_descr (DW_OP_addr, 0, 0);
+           ret->dw_loc_oprnd1.val_class = dw_val_class_addr;
+           ret->dw_loc_oprnd1.v.val_addr = rtl;
+           indirect_size = GET_MODE_SIZE (mode);
+         }
+       else
+         {
+           if (GET_CODE (rtl) == MEM)
+             {
+               indirect_size = GET_MODE_SIZE (mode);
+               rtl = XEXP (rtl, 0);
+             }
+           ret = mem_loc_descriptor (rtl, mode);
+         }
+      }
+      break;
+
+    case INDIRECT_REF:
+      ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+      indirect_size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (loc)));
+      break;
+
+    case COMPONENT_REF:
+    case BIT_FIELD_REF:
+    case ARRAY_REF:
+      {
+       tree obj, offset;
+       HOST_WIDE_INT bitsize, bitpos, bytepos;
+       enum machine_mode mode;
+       int volatilep;
+       unsigned int alignment;
+
+       obj = get_inner_reference (loc, &bitsize, &bitpos, &offset, &mode,
+                                  &unsignedp, &volatilep, &alignment);
+       ret = loc_descriptor_from_tree (obj, 1);
+
+       if (offset != NULL_TREE)
+         {
+           /* Variable offset.  */
+           add_loc_descr (&ret, loc_descriptor_from_tree (offset, 0));
+           add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0));
+         }
+
+       if (addressp)
+         {
+           /* We cannot address anything not on a unit boundary.  */
+           if (bitpos % BITS_PER_UNIT != 0)
+             abort ();
+         }
+       else
+         {
+           if (bitpos % BITS_PER_UNIT != 0
+               || bitsize % BITS_PER_UNIT != 0)
+             {
+               /* ??? We could handle this by loading and shifting etc.
+                  Wait until someone needs it before expending the effort.  */
+               abort ();
+             }
+
+           indirect_size = bitsize / BITS_PER_UNIT;
+         }
+
+       bytepos = bitpos / BITS_PER_UNIT;
+       if (bytepos > 0)
+         add_loc_descr (&ret, new_loc_descr (DW_OP_plus_uconst, bytepos, 0));
+       else if (bytepos < 0)
+         {
+           add_loc_descr (&ret, int_loc_descriptor (bytepos));
+           add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0));
+         }
+       break;
+      }
+
+    case INTEGER_CST:
+      if (host_integerp (loc, 0))
+       ret = int_loc_descriptor (tree_low_cst (loc, 0));
+      break;
+      break;
+
+    case BIT_AND_EXPR:
+      op = DW_OP_and;
+      goto do_binop;
+    case BIT_XOR_EXPR:
+      op = DW_OP_xor;
+      goto do_binop;
+    case BIT_IOR_EXPR:
+      op = DW_OP_or;
+      goto do_binop;
+    case TRUNC_DIV_EXPR:
+      op = DW_OP_div;
+      goto do_binop;
+    case MINUS_EXPR:
+      op = DW_OP_minus;
+      goto do_binop;
+    case TRUNC_MOD_EXPR:
+      op = DW_OP_mod;
+      goto do_binop;
+    case MULT_EXPR:
+      op = DW_OP_mul;
+      goto do_binop;
+    case LSHIFT_EXPR:
+      op = DW_OP_shl;
+      goto do_binop;
+    case RSHIFT_EXPR:
+      op = (unsignedp ? DW_OP_shr : DW_OP_shra);
+      goto do_binop;
+    case PLUS_EXPR:
+      if (TREE_CODE (TREE_OPERAND (loc, 1)) == INTEGER_CST
+         && host_integerp (TREE_OPERAND (loc, 1), 0))
+       {
+         ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+         add_loc_descr (&ret,
+                        new_loc_descr (DW_OP_plus_uconst,
+                                       tree_low_cst (TREE_OPERAND (loc, 1),
+                                                     0),
+                                       0));
+         break;
+       }
+      op = DW_OP_plus;
+      goto do_binop;
+    case LE_EXPR:
+      if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+       break;
+      op = DW_OP_le;
+      goto do_binop;
+    case GE_EXPR:
+      if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+       break;
+      op = DW_OP_ge;
+      goto do_binop;
+    case LT_EXPR:
+      if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+       break;
+      op = DW_OP_lt;
+      goto do_binop;
+    case GT_EXPR:
+      if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+       break;
+      op = DW_OP_gt;
+      goto do_binop;
+    case EQ_EXPR:
+      op = DW_OP_eq;
+      goto do_binop;
+    case NE_EXPR:
+      op = DW_OP_ne;
+      goto do_binop;
+
+    do_binop:
+      ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+      add_loc_descr (&ret, loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0));
+      add_loc_descr (&ret, new_loc_descr (op, 0, 0));
+      break;
+
+    case BIT_NOT_EXPR:
+      op = DW_OP_not;
+      goto do_unop;
+    case ABS_EXPR:
+      op = DW_OP_abs;
+      goto do_unop;
+    case NEGATE_EXPR:
+      op = DW_OP_neg;
+      goto do_unop;
+
+    do_unop:
+      ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+      add_loc_descr (&ret, new_loc_descr (op, 0, 0));
+      break;
+
+    case MAX_EXPR:
+      loc = build (COND_EXPR, TREE_TYPE (loc),
+                  build (LT_EXPR, integer_type_node,
+                         TREE_OPERAND (loc, 0), TREE_OPERAND (loc, 1)),
+                  TREE_OPERAND (loc, 1), TREE_OPERAND (loc, 0));
+      /* FALLTHRU */
+
+    case COND_EXPR:
+      {
+       dw_loc_descr_ref bra_node, jump_node, tmp;
+
+       ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+       bra_node = new_loc_descr (DW_OP_bra, 0, 0);
+       add_loc_descr (&ret, bra_node);
+
+       tmp = loc_descriptor_from_tree (TREE_OPERAND (loc, 2), 0);
+       add_loc_descr (&ret, tmp);
+       jump_node = new_loc_descr (DW_OP_skip, 0, 0);
+       add_loc_descr (&ret, jump_node);
+
+       tmp = loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0);
+       add_loc_descr (&ret, tmp);
+       bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
+       bra_node->dw_loc_oprnd1.v.val_loc = tmp;
+
+       /* ??? Need a node to point the skip at.  Use a nop.  */
+       tmp = new_loc_descr (DW_OP_nop, 0, 0);
+       add_loc_descr (&ret, tmp);
+       jump_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
+       jump_node->dw_loc_oprnd1.v.val_loc = tmp;
+      }
+      break;
+
+    default:
+      abort ();
+    }
+
+  /* If we can't fill the request for an address, die.  */
+  if (addressp && indirect_size == 0)
+    abort ();
+
+  /* If we've got an address and don't want one, dereference.  */
+  if (!addressp && indirect_size > 0)
+    {
+      if (indirect_size > DWARF2_ADDR_SIZE)
+       abort ();
+      if (indirect_size == DWARF2_ADDR_SIZE)
+       op = DW_OP_deref;
+      else
+       op = DW_OP_deref_size;
+      add_loc_descr (&ret, new_loc_descr (op, indirect_size, 0));
+    }
+
+  return ret;
+}
+
 /* Given a value, round it up to the lowest multiple of `boundary'
    which is not less than the value itself.  */
 
@@ -6864,17 +8068,17 @@ static inline unsigned HOST_WIDE_INT
 simple_type_size_in_bits (type)
      register tree type;
 {
+  tree type_size_tree;
+
   if (TREE_CODE (type) == ERROR_MARK)
     return BITS_PER_WORD;
-  else
-    {
-      register tree type_size_tree = TYPE_SIZE (type);
+  type_size_tree = TYPE_SIZE (type);
 
-      if (! host_integerp (type_size_tree, 1))
-       return TYPE_ALIGN (type);
-
-      return tree_low_cst (type_size_tree, 1);
-    }
+  if (type_size_tree == NULL_TREE)
+    return 0;
+  if (! host_integerp (type_size_tree, 1))
+    return TYPE_ALIGN (type);
+  return tree_low_cst (type_size_tree, 1);
 }
 
 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
@@ -6909,16 +8113,12 @@ field_byte_offset (decl)
   type = field_type (decl);
   field_size_tree = DECL_SIZE (decl);
 
-  /* If there was an error, the size could be zero.  */
+  /* The size could be unspecified if there was an error, or for
+     a flexible array member.  */
   if (! field_size_tree)
-    {
-      if (errorcount)
-       return 0;
-
-      abort ();
-    }
+    field_size_tree = bitsize_zero_node;
 
-  /* We cannot yet cope with fields whose positions are variable, so 
+  /* We cannot yet cope with fields whose positions are variable, so
      for now, when we see such things, we simply return 0.  Someday, we may
      be able to handle such cases, but it will be damn difficult.  */
   if (! host_integerp (bit_position (decl), 0))
@@ -6926,7 +8126,7 @@ field_byte_offset (decl)
 
   bitpos_int = int_bit_position (decl);
 
-    /* If we don't know the size of the field, pretend it's a full word.  */
+  /* If we don't know the size of the field, pretend it's a full word.  */
   if (host_integerp (field_size_tree, 1))
     field_size_in_bits = tree_low_cst (field_size_tree, 1);
   else
@@ -6940,7 +8140,7 @@ field_byte_offset (decl)
      the starting bit offset (relative to the start of the containing
      structure type) of the hypothetical "containing object" for a bit-
      field.  Thus, when computing the byte offset value for the start of the
-     "containing object" of a bit-field, we must deduce this information on 
+     "containing object" of a bit-field, we must deduce this information on
      our own. This can be rather tricky to do in some cases.  For example,
      handling the following structure type definition when compiling for an
      i386/i486 target (which only aligns long long's to 32-bit boundaries)
@@ -6950,7 +8150,7 @@ field_byte_offset (decl)
 
      Fortunately, there is a simple rule-of-thumb which can be
      used in such cases.  When compiling for an i386/i486, GCC will allocate
-     8 bytes for the structure shown above.  It decides to do this based upon 
+     8 bytes for the structure shown above.  It decides to do this based upon
      one simple rule for bit-field allocation.  Quite simply, GCC allocates
      each "containing object" for each bit-field at the first (i.e. lowest
      addressed) legitimate alignment boundary (based upon the required
@@ -6968,10 +8168,10 @@ field_byte_offset (decl)
      (As it turns out, for the example above, the compiler finds that it is
      OK to allocate the "containing object" 64-bit field at bit-offset zero
      within the structure type.) Here we attempt to work backwards from the
-     limited set of facts we're given, and we try to deduce from those facts, 
+     limited set of facts we're given, and we try to deduce from those facts,
      where GCC must have believed that the containing object started (within
-     the structure type). The value we deduce is then used (by the callers of 
-     this routine) to generate DW_AT_location and DW_AT_bit_offset attributes 
+     the structure type). The value we deduce is then used (by the callers of
+     this routine) to generate DW_AT_location and DW_AT_bit_offset attributes
      for fields (both bit-fields and, in the case of DW_AT_location, regular
      fields as well).  */
 
@@ -7014,13 +8214,13 @@ add_AT_location_description (die, attr_kind, rtl)
      of existence will have a DECL_RTL value which denotes a pseudo-reg.
      Currently, in some rare cases, variables can have DECL_RTL values which
      look like (MEM (REG pseudo-reg#)).  These cases are due to bugs
-     elsewhere in the compiler.  We treat such cases as if the variable(s) in 
+     elsewhere in the compiler.  We treat such cases as if the variable(s) in
      question had been optimized out of existence.  */
 
   if (is_pseudo_reg (rtl)
       || (GET_CODE (rtl) == MEM
          && is_pseudo_reg (XEXP (rtl, 0)))
-      /* This can happen for a PARM_DECL with a DECL_INCOMING_RTL which 
+      /* This can happen for a PARM_DECL with a DECL_INCOMING_RTL which
         references the internal argument pointer (a pseudo) in a function
         where all references to the internal argument pointer were
         eliminated via the optimizers.  */
@@ -7116,8 +8316,8 @@ add_const_value_attribute (die, rtl)
 
        if (GET_MODE_CLASS (mode) == MODE_FLOAT)
          {
-           register unsigned length = GET_MODE_SIZE (mode) / sizeof (long);
-           long array[4];
+           register unsigned length = GET_MODE_SIZE (mode) / 4;
+           long *array = (long *) xmalloc (sizeof (long) * length);
            REAL_VALUE_TYPE rv;
 
            REAL_VALUE_FROM_CONST_DOUBLE (rv, rtl);
@@ -7165,10 +8365,10 @@ add_const_value_attribute (die, rtl)
          variable (for the inlining) which acts as a stand-in for the
          corresponding formal parameter (of the inline function) will look
          like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).  This is not
-         exactly a compile-time constant expression, but it isn't the address 
-         of the (artificial) local variable either.  Rather, it represents the 
+         exactly a compile-time constant expression, but it isn't the address
+         of the (artificial) local variable either.  Rather, it represents the
          *value* which the artificial local variable always has during its
-         lifetime.  We currently have no way to represent such quasi-constant 
+         lifetime.  We currently have no way to represent such quasi-constant
          values in Dwarf, so for now we just punt and generate nothing.  */
       break;
 
@@ -7179,39 +8379,19 @@ add_const_value_attribute (die, rtl)
 
 }
 
-/* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
-   data attribute for a variable or a parameter.  We generate the
-   DW_AT_const_value attribute only in those cases where the given variable
-   or parameter does not have a true "location" either in memory or in a
-   register.  This can happen (for example) when a constant is passed as an
-   actual argument in a call to an inline function.  (It's possible that
-   these things can crop up in other ways also.)  Note that one type of
-   constant value which can be passed into an inlined function is a constant
-   pointer.  This can happen for example if an actual argument in an inlined
-   function call evaluates to a compile-time constant address.  */
-
-static void
-add_location_or_const_value_attribute (die, decl)
-     register dw_die_ref die;
-     register tree decl;
+static rtx
+rtl_for_decl_location (decl)
+     tree decl;
 {
   register rtx rtl;
-  register tree declared_type;
-  register tree passed_type;
-
-  if (TREE_CODE (decl) == ERROR_MARK)
-    return;
-
-  if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
-    abort ();
 
   /* Here we have to decide where we are going to say the parameter "lives"
      (as far as the debugger is concerned).  We only have a couple of
      choices.  GCC provides us with DECL_RTL and with DECL_INCOMING_RTL.
 
-     DECL_RTL normally indicates where the parameter lives during most of the 
+     DECL_RTL normally indicates where the parameter lives during most of the
      activation of the function.  If optimization is enabled however, this
-     could be either NULL or else a pseudo-reg.  Both of those cases indicate 
+     could be either NULL or else a pseudo-reg.  Both of those cases indicate
      that the parameter doesn't really live anywhere (as far as the code
      generation parts of GCC are concerned) during most of the function's
      activation.  That will happen (for example) if the parameter is never
@@ -7287,8 +8467,8 @@ add_location_or_const_value_attribute (die, decl)
     {
       if (rtl == NULL_RTX || is_pseudo_reg (rtl))
        {
-         declared_type = type_main_variant (TREE_TYPE (decl));
-         passed_type = type_main_variant (DECL_ARG_TYPE (decl));
+         tree declared_type = type_main_variant (TREE_TYPE (decl));
+         tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
 
          /* This decl represents a formal parameter which was optimized out.
             Note that DECL_INCOMING_RTL may be NULL in here, but we handle
@@ -7299,7 +8479,7 @@ add_location_or_const_value_attribute (die, decl)
                   && TREE_CODE (declared_type) == INTEGER_TYPE
                   && (GET_MODE_SIZE (TYPE_MODE (declared_type))
                       <= GET_MODE_SIZE (TYPE_MODE (passed_type))))
-               rtl = DECL_INCOMING_RTL (decl);
+           rtl = DECL_INCOMING_RTL (decl);
        }
 
       /* If the parm was passed in registers, but lives on the stack, then
@@ -7335,14 +8515,45 @@ add_location_or_const_value_attribute (die, decl)
        }
     }
 
-  if (rtl == NULL_RTX)
-    return;
-
-  rtl = eliminate_regs (rtl, 0, NULL_RTX);
+  if (rtl != NULL_RTX)
+    {
+      rtl = eliminate_regs (rtl, 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
-  if (current_function_uses_only_leaf_regs)
-    leaf_renumber_regs_insn (rtl);
+      if (current_function_uses_only_leaf_regs)
+       leaf_renumber_regs_insn (rtl);
 #endif
+    }
+
+  return rtl;
+}
+
+/* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
+   data attribute for a variable or a parameter.  We generate the
+   DW_AT_const_value attribute only in those cases where the given variable
+   or parameter does not have a true "location" either in memory or in a
+   register.  This can happen (for example) when a constant is passed as an
+   actual argument in a call to an inline function.  (It's possible that
+   these things can crop up in other ways also.)  Note that one type of
+   constant value which can be passed into an inlined function is a constant
+   pointer.  This can happen for example if an actual argument in an inlined
+   function call evaluates to a compile-time constant address.  */
+
+static void
+add_location_or_const_value_attribute (die, decl)
+     register dw_die_ref die;
+     register tree decl;
+{
+  register rtx rtl;
+
+  if (TREE_CODE (decl) == ERROR_MARK)
+    return;
+
+  if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
+    abort ();
+
+  rtl = rtl_for_decl_location (decl);
+  if (rtl == NULL_RTX)
+    return;
 
   switch (GET_CODE (rtl))
     {
@@ -7374,6 +8585,40 @@ add_location_or_const_value_attribute (die, decl)
     }
 }
 
+/* If we don't have a copy of this variable in memory for some reason (such
+   as a C++ member constant that doesn't have an out-of-line definition),
+   we should tell the debugger about the constant value.  */
+
+static void
+tree_add_const_value_attribute (var_die, decl)
+     dw_die_ref var_die;
+     tree decl;
+{
+  tree init = DECL_INITIAL (decl);
+  tree type = TREE_TYPE (decl);
+
+  if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl) && init
+      && initializer_constant_valid_p (init, type) == null_pointer_node)
+    /* OK */;
+  else
+    return;
+
+  switch (TREE_CODE (type))
+    {
+    case INTEGER_TYPE:
+      if (host_integerp (init, 0))
+       add_AT_unsigned (var_die, DW_AT_const_value,
+                        TREE_INT_CST_LOW (init));
+      else
+       add_AT_long_long (var_die, DW_AT_const_value,
+                         TREE_INT_CST_HIGH (init),
+                         TREE_INT_CST_LOW (init));
+      break;
+
+    default:;
+    }
+}
+
 /* Generate an DW_AT_name attribute given some string value to be included as
    the value of the attribute.  */
 
@@ -7415,7 +8660,7 @@ add_bound_info (subrange_die, bound_attr, bound)
     case INTEGER_CST:
       if (! host_integerp (bound, 0)
          || (bound_attr == DW_AT_lower_bound
-             && ((is_c_family () && integer_zerop (bound))
+             && (((is_c_family () || is_java ()) &&  integer_zerop (bound))
                  || (is_fortran () && integer_onep (bound)))))
        /* use the default */
        ;
@@ -7428,7 +8673,7 @@ add_bound_info (subrange_die, bound_attr, bound)
     case NON_LVALUE_EXPR:
       add_bound_info (subrange_die, bound_attr, TREE_OPERAND (bound, 0));
       break;
-      
+
     case SAVE_EXPR:
       /* If optimization is turned on, the SAVE_EXPRs that describe how to
          access the upper bound values may be bogus.  If they refer to a
@@ -7479,15 +8724,43 @@ add_bound_info (subrange_die, bound_attr, bound)
       /* Else leave out the attribute.  */
       break;
 
-    case MAX_EXPR:
     case VAR_DECL:
-    case COMPONENT_REF:
-      /* ??? These types of bounds can be created by the Ada front end,
-        and it isn't clear how to emit debug info for them.  */
-      break;
+    case PARM_DECL:
+      {
+       dw_die_ref decl_die = lookup_decl_die (bound);
+
+       /* ??? Can this happen, or should the variable have been bound
+          first?  Probably it can, since I imagine that we try to create
+          the types of parameters in the order in which they exist in
+          the list, and won't have created a forward reference to a
+          later parameter.  */
+       if (decl_die != NULL)
+         add_AT_die_ref (subrange_die, bound_attr, decl_die);
+       break;
+      }
 
     default:
-      abort ();
+      {
+       /* Otherwise try to create a stack operation procedure to
+          evaluate the value of the array bound.  */
+
+       dw_die_ref ctx, decl_die;
+       dw_loc_descr_ref loc;
+
+       loc = loc_descriptor_from_tree (bound, 0);
+       if (loc == NULL)
+         break;
+
+       ctx = lookup_decl_die (current_function_decl);
+
+       decl_die = new_die (DW_TAG_variable, ctx);
+       add_AT_flag (decl_die, DW_AT_artificial, 1);
+       add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
+       add_AT_loc (decl_die, DW_AT_location, loc);
+
+       add_AT_die_ref (subrange_die, bound_attr, decl_die);
+       break;
+      }
     }
 }
 
@@ -7505,13 +8778,13 @@ add_subscript_info (type_die, type)
   register tree lower, upper;
   register dw_die_ref subrange_die;
 
-  /* The GNU compilers represent multidimensional array types as sequences of 
+  /* The GNU compilers represent multidimensional array types as sequences of
      one dimensional array types whose element types are themselves array
      types.  Here we squish that down, so that each multidimensional array
-     type gets only one array_type DIE in the Dwarf debugging info. The draft 
+     type gets only one array_type DIE in the Dwarf debugging info. The draft
      Dwarf specification say that we are allowed to do this kind of
      compression in C (because there is no difference between an array or
-     arrays and a multidimensional array in C) but for other source languages 
+     arrays and a multidimensional array in C) but for other source languages
      (e.g. Ada) we probably shouldn't do this.  */
 
   /* ??? The SGI dwarf reader fails for multidimensional arrays with a
@@ -7527,7 +8800,7 @@ add_subscript_info (type_die, type)
       register tree domain = TYPE_DOMAIN (type);
 
       /* Arrays come in three flavors: Unspecified bounds, fixed bounds,
-        and (in GNU C only) variable bounds.  Handle all three forms 
+        and (in GNU C only) variable bounds.  Handle all three forms
          here.  */
       subrange_die = new_die (DW_TAG_subrange_type, type_die);
       if (domain)
@@ -7546,7 +8819,7 @@ add_subscript_info (type_die, type)
                  && TYPE_NAME (domain) == NULL_TREE
                  && TREE_CODE (TREE_TYPE (domain)) == INTEGER_TYPE
                  && TYPE_NAME (TREE_TYPE (domain)) == NULL_TREE)
-               ;       
+               ;
              else
                add_type_attribute (subrange_die, TREE_TYPE (domain), 0, 0,
                                    type_die);
@@ -7567,8 +8840,7 @@ add_subscript_info (type_die, type)
        /* We have an array type with an unspecified length.  The DWARF-2
             spec does not say how to handle this; let's just leave out the
             bounds.  */
-       {;}
-      
+        {;}
 
 #ifndef MIPS_DEBUGGING_INFO
     }
@@ -7656,8 +8928,8 @@ add_bit_offset_attribute (die, decl)
   bitpos_int = int_bit_position (decl);
 
   /* Note that the bit offset is always the distance (in bits) from the
-     highest-order bit of the "containing object" to the highest-order bit of 
-     the bit-field itself.  Since the "high-order end" of any object or field 
+     highest-order bit of the "containing object" to the highest-order bit of
+     the bit-field itself.  Since the "high-order end" of any object or field
      is different on big-endian and little-endian machines, the computation
      below must take account of these differences.  */
   highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
@@ -7707,7 +8979,6 @@ add_prototyped_attribute (die, func_type)
     add_AT_flag (die, DW_AT_prototyped, 1);
 }
 
-
 /* Add an 'abstract_origin' attribute below a given DIE.  The DIE is found
    by looking in either the type declaration or object declaration
    equate table.  */
@@ -7742,7 +9013,7 @@ add_abstract_origin_attribute (die, origin)
 
   if (origin_die == NULL)
     abort ();
-  
+
   add_AT_die_ref (die, DW_AT_abstract_origin, origin_die);
 }
 
@@ -7777,7 +9048,8 @@ add_src_coords_attributes (die, decl)
      register dw_die_ref die;
      register tree decl;
 {
-  register unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
+  register unsigned file_index = lookup_filename (&decl_file_table,
+                                                 DECL_SOURCE_FILE (decl));
 
   add_AT_unsigned (die, DW_AT_decl_file, file_index);
   add_AT_unsigned (die, DW_AT_decl_line, DECL_SOURCE_LINE (decl));
@@ -7793,7 +9065,7 @@ add_name_and_src_coords_attributes (die, decl)
 {
   register tree decl_name;
 
-  decl_name = DECL_NAME (decl); 
+  decl_name = DECL_NAME (decl);
   if (decl_name != NULL && IDENTIFIER_POINTER (decl_name) != NULL)
     {
       add_name_attribute (die, dwarf2_name (decl, 0));
@@ -7808,7 +9080,7 @@ add_name_and_src_coords_attributes (die, decl)
     }
 }
 
-/* Push a new declaration scope. */
+/* Push a new declaration scope.  */
 
 static void
 push_decl_scope (scope)
@@ -7844,8 +9116,8 @@ pop_decl_scope ()
 
 static dw_die_ref
 scope_die_for (t, context_die)
-    register tree t; 
-    register dw_die_ref context_die;
+     register tree t;
+     register dw_die_ref context_die;
 {
   register dw_die_ref scope_die = NULL;
   register tree containing_scope;
@@ -7981,7 +9253,7 @@ type_tag (type)
       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
        t = TYPE_NAME (type);
 
-      /* The g++ front end makes the TYPE_NAME of *each* tagged type point to 
+      /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
          a TYPE_DECL node, regardless of whether or not a `typedef' was
          involved.  */
       else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
@@ -8268,7 +9540,6 @@ gen_enumeration_type_die (type, context_die)
     add_AT_flag (type_die, DW_AT_declaration, 1);
 }
 
-
 /* Generate a DIE to represent either a real live formal parameter decl or to
    represent just the type of some formal parameter position in some function
    type.
@@ -8356,20 +9627,20 @@ gen_formal_types_die (function_or_method_type, context_die)
      non-static member function type, skip over the first thing on the
      TYPE_ARG_TYPES list because it only represents the type of the hidden
      `this pointer'.  The debugger should be able to figure out (without
-     being explicitly told) that this non-static member function type takes a 
-     `this pointer' and should be able to figure what the type of that hidden 
+     being explicitly told) that this non-static member function type takes a
+     `this pointer' and should be able to figure what the type of that hidden
      parameter is from the DW_AT_member attribute of the parent
      DW_TAG_subroutine_type DIE.  */
   if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
     first_parm_type = TREE_CHAIN (first_parm_type);
 #endif
 
-  /* Make our first pass over the list of formal parameter types and output a 
+  /* Make our first pass over the list of formal parameter types and output a
      DW_TAG_formal_parameter DIE for each one.  */
   for (link = first_parm_type; link; link = TREE_CHAIN (link))
     {
       register dw_die_ref parm_die;
-      
+
       formal_type = TREE_VALUE (link);
       if (formal_type == void_type_node)
        break;
@@ -8386,7 +9657,7 @@ gen_formal_types_die (function_or_method_type, context_die)
   if (formal_type != void_type_node)
     gen_unspecified_parameters_die (function_or_method_type, context_die);
 
-  /* Make our second (and final) pass over the list of formal parameter types 
+  /* Make our second (and final) pass over the list of formal parameter types
      and output DIEs to represent those types (as necessary).  */
   for (link = TYPE_ARG_TYPES (function_or_method_type);
        link;
@@ -8515,7 +9786,7 @@ gen_subprogram_die (decl, context_die)
   else if (old_die)
     {
       register unsigned file_index
-       = lookup_filename (DECL_SOURCE_FILE (decl));
+       = lookup_filename (&decl_file_table, DECL_SOURCE_FILE (decl));
 
       if (get_AT_flag (old_die, DW_AT_declaration) != 1)
        {
@@ -8541,7 +9812,7 @@ gen_subprogram_die (decl, context_die)
          && (DECL_ARTIFICIAL (decl)
              || (get_AT_unsigned (old_die, DW_AT_decl_file) == file_index
                  && (get_AT_unsigned (old_die, DW_AT_decl_line)
-                     == (unsigned)DECL_SOURCE_LINE (decl)))))
+                     == (unsigned) DECL_SOURCE_LINE (decl)))))
        {
          subr_die = old_die;
 
@@ -8556,7 +9827,7 @@ gen_subprogram_die (decl, context_die)
          if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index)
            add_AT_unsigned (subr_die, DW_AT_decl_file, file_index);
          if (get_AT_unsigned (old_die, DW_AT_decl_line)
-             != (unsigned)DECL_SOURCE_LINE (decl))
+             != (unsigned) DECL_SOURCE_LINE (decl))
            add_AT_unsigned
              (subr_die, DW_AT_decl_line, DECL_SOURCE_LINE (decl));
        }
@@ -8564,7 +9835,7 @@ gen_subprogram_die (decl, context_die)
   else
     {
       subr_die = new_die (DW_TAG_subprogram, context_die);
-                        
+
       if (TREE_PUBLIC (decl))
        add_AT_flag (subr_die, DW_AT_external, 1);
 
@@ -8654,17 +9925,17 @@ gen_subprogram_die (decl, context_die)
     }
 
   /* Now output descriptions of the arguments for this function. This gets
-     (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list 
+     (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list
      for a FUNCTION_DECL doesn't indicate cases where there was a trailing
      `...' at the end of the formal parameter list.  In order to find out if
      there was a trailing ellipsis or not, we must instead look at the type
      associated with the FUNCTION_DECL.  This will be a node of type
      FUNCTION_TYPE. If the chain of type nodes hanging off of this
-     FUNCTION_TYPE node ends with a void_type_node then there should *not* be 
+     FUNCTION_TYPE node ends with a void_type_node then there should *not* be
      an ellipsis at the end.  */
 
   /* In the case where we are describing a mere function declaration, all we
-     need to do here (and all we *can* do here) is to describe the *types* of 
+     need to do here (and all we *can* do here) is to describe the *types* of
      its formal parameters.  */
   if (debug_info_level <= DINFO_LEVEL_TERSE)
     ;
@@ -8690,7 +9961,7 @@ gen_subprogram_die (decl, context_die)
          }
 
       /* Decide whether we need a unspecified_parameters DIE at the end.
-         There are 2 more cases to do this for: 1) the ansi ... declaration - 
+         There are 2 more cases to do this for: 1) the ansi ... declaration -
          this is detectable when the end of the arg list is not a
          void_type_node 2) an unprototyped function declaration (not a
          definition).  This just means that we have no info about the
@@ -8772,13 +10043,13 @@ gen_variable_die (decl, context_die)
       if (DECL_NAME (decl))
        {
          register unsigned file_index
-           = lookup_filename (DECL_SOURCE_FILE (decl));
+           = lookup_filename (&decl_file_table, DECL_SOURCE_FILE (decl));
 
          if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index)
            add_AT_unsigned (var_die, DW_AT_decl_file, file_index);
 
          if (get_AT_unsigned (old_die, DW_AT_decl_line)
-             != (unsigned)DECL_SOURCE_LINE (decl))
+             != (unsigned) DECL_SOURCE_LINE (decl))
 
            add_AT_unsigned (var_die, DW_AT_decl_line,
                             DECL_SOURCE_LINE (decl));
@@ -8806,7 +10077,7 @@ gen_variable_die (decl, context_die)
 
   if (declaration)
     add_AT_flag (var_die, DW_AT_declaration, 1);
-  
+
   if (class_scope_p (context_die) || DECL_ABSTRACT (decl))
     equate_decl_number_to_die (decl, var_die);
 
@@ -8815,6 +10086,8 @@ gen_variable_die (decl, context_die)
       add_location_or_const_value_attribute (var_die, decl);
       add_pubname (decl, var_die);
     }
+  else
+    tree_add_const_value_attribute (var_die, decl);
 }
 
 /* Generate a DIE to represent a label identifier.  */
@@ -8828,7 +10101,6 @@ gen_label_die (decl, context_die)
   register dw_die_ref lbl_die = new_die (DW_TAG_label, context_die);
   register rtx insn;
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
-  char label2[MAX_ARTIFICIAL_LABEL_BYTES];
 
   if (origin != NULL)
     add_abstract_origin_attribute (lbl_die, origin);
@@ -8848,17 +10120,15 @@ gen_label_die (decl, context_die)
          || ((GET_CODE (insn) == NOTE
               && NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED_LABEL)))
        {
-         /* When optimization is enabled (via -O) some parts of the compiler 
-            (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which 
+         /* When optimization is enabled (via -O) some parts of the compiler
+            (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
             represent source-level labels which were explicitly declared by
             the user.  This really shouldn't be happening though, so catch
             it if it ever does happen.  */
          if (INSN_DELETED_P (insn))
            abort ();
 
-         sprintf (label2, INSN_LABEL_FMT, current_funcdef_number);
-         ASM_GENERATE_INTERNAL_LABEL (label, label2,
-                                      (unsigned) INSN_UID (insn));
+         ASM_GENERATE_INTERNAL_LABEL (label, "L", CODE_LABEL_NUMBER (insn));
          add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
        }
     }
@@ -9044,6 +10314,8 @@ gen_compile_unit_die (filename)
     language = DW_LANG_Fortran77;
   else if (strcmp (language_string, "GNU Pascal") == 0)
     language = DW_LANG_Pascal83;
+  else if (strcmp (language_string, "GNU Java") == 0)
+    language = DW_LANG_Java;
   else if (flag_traditional)
     language = DW_LANG_C;
   else
@@ -9067,7 +10339,7 @@ gen_string_type_die (type, context_die)
   equate_type_number_to_die (type, type_die);
 
   /* Fudge the string length attribute for now.  */
-  
+
   /* TODO: add string length info.
    string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
                              bound_representation (upper_bound, 0, 'u'); */
@@ -9107,12 +10379,12 @@ gen_member_die (type, context_die)
      members. Note that as we output the DIEs necessary to represent the
      members of this record or union type, we will also be trying to output
      DIEs to represent the *types* of those members. However the `type'
-     function (above) will specifically avoid generating type DIEs for member 
-     types *within* the list of member DIEs for this (containing) type execpt 
+     function (above) will specifically avoid generating type DIEs for member
+     types *within* the list of member DIEs for this (containing) type execpt
      for those types (of members) which are explicitly marked as also being
      members of this (containing) type themselves.  The g++ front- end can
      force any given type to be treated as a member of some other
-     (containing) type by setting the TYPE_CONTEXT of the given (member) type 
+     (containing) type by setting the TYPE_CONTEXT of the given (member) type
      to point to the TREE node representing the appropriate (containing)
      type.  */
 
@@ -9187,9 +10459,10 @@ gen_struct_or_union_type_die (type, context_die)
                          ? DW_TAG_structure_type : DW_TAG_union_type,
                          scope_die);
       equate_type_number_to_die (type, type_die);
-      add_name_attribute (type_die, type_tag (type));
       if (old_die)
        add_AT_die_ref (type_die, DW_AT_specification, old_die);
+      else
+       add_name_attribute (type_die, type_tag (type));
     }
   else
     remove_AT (type_die, DW_AT_declaration);
@@ -9198,7 +10471,7 @@ gen_struct_or_union_type_die (type, context_die)
      then give a list of members.  */
   if (complete)
     {
-      /* Prevent infinite recursion in cases where the type of some member of 
+      /* Prevent infinite recursion in cases where the type of some member of
          this type is expressed in terms of this type itself.  */
       TREE_ASM_WRITTEN (type) = 1;
       add_byte_size_attribute (type_die, type);
@@ -9314,7 +10587,7 @@ gen_type_die (type, context_die)
 
   if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
       && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
-    { 
+    {
       TREE_ASM_WRITTEN (type) = 1;
       gen_decl_die (TYPE_NAME (type), context_die);
       return;
@@ -9340,7 +10613,7 @@ gen_type_die (type, context_die)
       break;
 
     case OFFSET_TYPE:
-      /* This code is used for C++ pointer-to-data-member types. 
+      /* This code is used for C++ pointer-to-data-member types.
         Output a description of the relevant class type.  */
       gen_type_die (TYPE_OFFSET_BASETYPE (type), context_die);
 
@@ -9468,7 +10741,7 @@ gen_tagged_type_instantiation_die (type, context_die)
 
   /* Do not check TREE_ASM_WRITTEN (type) as it may not be set if this is
      an instance of an unresolved type.  */
-  
+
   switch (TREE_CODE (type))
     {
     case ERROR_MARK:
@@ -9529,7 +10802,7 @@ gen_block_die (stmt, context_die, depth)
   else
     {
       /* In the case where the current block represents an inlining of the
-         "body block" of an inline function, we must *NOT* output any DIE for 
+         "body block" of an inline function, we must *NOT* output any DIE for
          this block because we have already output a DIE to represent the
          whole inlined function scope and the "body block" of any function
          doesn't really represent a different scope according to ANSI C
@@ -9661,7 +10934,7 @@ gen_decl_die (decl, context_die)
   switch (TREE_CODE (decl))
     {
     case CONST_DECL:
-      /* The individual enumerators of an enum type get output when we output 
+      /* The individual enumerators of an enum type get output when we output
          the Dwarf representation of the relevant enum type itself.  */
       break;
 
@@ -9675,7 +10948,11 @@ gen_decl_die (decl, context_die)
       /* If we're emitting an out-of-line copy of an inline function,
         emit info for the abstract instance and set up to refer to it.  */
       if (DECL_INLINE (decl) && ! DECL_ABSTRACT (decl)
-         && ! class_scope_p (context_die))
+         && ! class_scope_p (context_die)
+         /* gen_abstract_function won't emit a die if this is just a
+            declaration.  We must avoid setting DECL_ABSTRACT_ORIGIN in
+            that case, because that works only if we have a die.  */
+         && DECL_INITIAL (decl) != NULL_TREE)
        {
          gen_abstract_function (decl);
          set_decl_origin_self (decl);
@@ -9707,12 +10984,12 @@ gen_decl_die (decl, context_die)
       if (debug_info_level <= DINFO_LEVEL_TERSE)
        break;
 
-      /* In the special case of a TYPE_DECL node representing the 
+      /* In the special case of a TYPE_DECL node representing the
          declaration of some type tag, if the given TYPE_DECL is marked as
          having been instantiated from some other (original) TYPE_DECL node
          (e.g. one which was generated within the original definition of an
          inline function) we have to generate a special (abbreviated)
-         DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type 
+         DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type
          DIE here.  */
       if (TYPE_DECL_IS_STUB (decl) && decl_ultimate_origin (decl) != NULL_TREE)
        {
@@ -9795,13 +11072,13 @@ dwarf2out_add_library_unit_info (filename, context_list)
   if (filename != NULL)
     {
       dw_die_ref unit_die = new_die (DW_TAG_module, comp_unit_die);
-      tree context_list_decl 
+      tree context_list_decl
        = build_decl (LABEL_DECL, get_identifier (context_list),
                      void_type_node);
 
       TREE_PUBLIC (context_list_decl) = TRUE;
       add_name_attribute (unit_die, context_list);
-      file_index = lookup_filename (filename);
+      file_index = lookup_filename (&decl_file_table, filename);
       add_AT_unsigned (unit_die, DW_AT_decl_file, file_index);
       add_pubname (context_list_decl, unit_die);
     }
@@ -9825,7 +11102,7 @@ dwarf2out_decl (decl)
   switch (TREE_CODE (decl))
     {
     case FUNCTION_DECL:
-      /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a 
+      /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
          builtin function.  Explicit programmer-supplied declarations of
          these same functions should NOT be ignored however.  */
       if (DECL_EXTERNAL (decl) && DECL_BUILT_IN (decl))
@@ -9834,12 +11111,12 @@ dwarf2out_decl (decl)
       /* What we would really like to do here is to filter out all mere
          file-scope declarations of file-scope functions which are never
          referenced later within this translation unit (and keep all of ones
-         that *are* referenced later on) but we aren't clairvoyant, so we have 
-         no idea which functions will be referenced in the future (i.e. later 
+         that *are* referenced later on) but we aren't clairvoyant, so we have
+         no idea which functions will be referenced in the future (i.e. later
          on within the current translation unit). So here we just ignore all
-         file-scope function declarations which are not also definitions.  If 
+         file-scope function declarations which are not also definitions.  If
          and when the debugger needs to know something about these functions,
-         it will have to hunt around and find the DWARF information associated 
+         it will have to hunt around and find the DWARF information associated
          with the definition of the function.  Note that we can't just check
          `DECL_EXTERNAL' to find out which FUNCTION_DECL nodes represent
          definitions and which ones represent mere declarations.  We have to
@@ -9848,13 +11125,13 @@ dwarf2out_decl (decl)
          definitions.  These can get inlined within the current translation
          unit (an thus, we need to generate DWARF info for their abstract
          instances so that the DWARF info for the concrete inlined instances
-         can have something to refer to) but the compiler never generates any 
+         can have something to refer to) but the compiler never generates any
          out-of-lines instances of such things (despite the fact that they
          *are* definitions).  The important point is that the C front-end
          marks these "extern inline" functions as DECL_EXTERNAL, but we need
          to generate DWARF for them anyway. Note that the C++ front-end also
          plays some similar games for inline function definitions appearing
-         within include files which also contain 
+         within include files which also contain
         `#pragma interface' pragmas.  */
       if (DECL_INITIAL (decl) == NULL_TREE)
        return;
@@ -9868,7 +11145,7 @@ dwarf2out_decl (decl)
       break;
 
     case VAR_DECL:
-      /* Ignore this VAR_DECL if it refers to a file-scope extern data object 
+      /* Ignore this VAR_DECL if it refers to a file-scope extern data object
          declaration and if the declaration was never even referenced from
          within this entire compilation unit.  We suppress these DIEs in
          order to save space in the .debug section (by eliminating entries
@@ -9930,7 +11207,7 @@ dwarf2out_begin_block (blocknum)
      register unsigned blocknum;
 {
   function_section (current_function_decl);
-  ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
+  ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
 }
 
 /* Output a marker (i.e. a label) for the end of the generated code for a
@@ -9941,7 +11218,7 @@ dwarf2out_end_block (blocknum)
      register unsigned blocknum;
 {
   function_section (current_function_decl);
-  ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum);
+  ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum);
 }
 
 /* Returns nonzero if it is appropriate not to emit any debugging
@@ -9963,24 +11240,6 @@ dwarf2out_ignore_block (block)
   return 1;
 }
 
-/* Output a marker (i.e. a label) at a point in the assembly code which
-   corresponds to a given source level label.  */
-
-void
-dwarf2out_label (insn)
-     register rtx insn;
-{
-  char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
-  if (debug_info_level >= DINFO_LEVEL_NORMAL)
-    {
-      function_section (current_function_decl);
-      sprintf (label, INSN_LABEL_FMT, current_funcdef_number);
-      ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, label,
-                                (unsigned) INSN_UID (insn));
-    }
-}
-
 /* Lookup a filename (in the list of filenames that we know about here in
    dwarf2out.c) and return its "index".  The index of each (known) filename is
    just a unique number which is associated with only that one filename.
@@ -9993,41 +11252,54 @@ dwarf2out_label (insn)
    was looked up last.  This handles the majority of all searches.  */
 
 static unsigned
-lookup_filename (file_name)
+lookup_filename (t, file_name)
+     struct file_table *t;
      const char *file_name;
 {
-  static unsigned last_file_lookup_index = 0;
   register unsigned i;
 
-  /* Check to see if the file name that was searched on the previous call
-     matches this file name. If so, return the index.  */
-  if (last_file_lookup_index != 0)
-    if (strcmp (file_name, file_table[last_file_lookup_index]) == 0)
-      return last_file_lookup_index;
+  /* Check to see if the file name that was searched on the previous
+     call matches this file name.  If so, return the index.  */
+  if (t->last_lookup_index != 0)
+    if (strcmp (file_name, t->table[t->last_lookup_index]) == 0)
+      return t->last_lookup_index;
 
   /* Didn't match the previous lookup, search the table */
-  for (i = 1; i < file_table_in_use; ++i)
-    if (strcmp (file_name, file_table[i]) == 0)
+  for (i = 1; i < t->in_use; ++i)
+    if (strcmp (file_name, t->table[i]) == 0)
       {
-       last_file_lookup_index = i;
+       t->last_lookup_index = i;
        return i;
       }
 
-  /* Prepare to add a new table entry by making sure there is enough space in 
+  /* Prepare to add a new table entry by making sure there is enough space in
      the table to do so.  If not, expand the current table.  */
-  if (file_table_in_use == file_table_allocated)
+  if (i == t->allocated)
     {
-      file_table_allocated += FILE_TABLE_INCREMENT;
-      file_table
-       = (char **) xrealloc (file_table,
-                             file_table_allocated * sizeof (char *));
+      t->allocated = i + FILE_TABLE_INCREMENT;
+      t->table = (char **)
+       xrealloc (t->table, t->allocated * sizeof (char *));
     }
 
   /* Add the new entry to the end of the filename table.  */
-  file_table[file_table_in_use] = xstrdup (file_name);
-  last_file_lookup_index = file_table_in_use++;
+  t->table[i] = xstrdup (file_name);
+  t->in_use = i + 1;
+  t->last_lookup_index = i;
 
-  return last_file_lookup_index;
+  return i;
+}
+
+static void
+init_file_table (t)
+     struct file_table *t;
+{
+  /* Allocate the initial hunk of the file_table.  */
+  t->table = (char **) xcalloc (FILE_TABLE_INCREMENT, sizeof (char *));
+  t->allocated = FILE_TABLE_INCREMENT;
+
+  /* Skip the first entry - file numbers begin at 1.  */
+  t->in_use = 1;
+  t->last_lookup_index = 0;
 }
 
 /* Output a label to mark the beginning of a source code line entry
@@ -10045,19 +11317,26 @@ dwarf2out_line (filename, line)
 
       if (DWARF2_ASM_LINE_DEBUG_INFO)
        {
-         static const char *lastfile;
+         unsigned old_in_use = line_file_table.in_use;
+         unsigned file_num = lookup_filename (&line_file_table, filename);
 
          /* Emit the .file and .loc directives understood by GNU as.  */
-         if (lastfile == 0 || strcmp (filename, lastfile))
+#if 0
+         /* ??? As of 2000-11-25, gas has a bug in which it doesn't
+            actually use the file number argument.  It merely remembers
+            the last .file directive emitted.  */
+         if (file_num >= old_in_use)
+           fprintf (asm_out_file, "\t.file %d \"%s\"\n", file_num, filename);
+         fprintf (asm_out_file, "\t.loc %d %d 0\n", file_num, line);
+#else
+         static int last_file_num;
+         if (file_num != last_file_num)
            {
-             if (lastfile == 0)
-               ggc_add_string_root ((char **) &lastfile, 1);
-
+             last_file_num = file_num;
              fprintf (asm_out_file, "\t.file 0 \"%s\"\n", filename);
-             lastfile = filename;
            }
-
          fprintf (asm_out_file, "\t.loc 0 %d 0\n", line);
+#endif
 
          /* Indicate that line number info exists.  */
          ++line_info_table_in_use;
@@ -10090,7 +11369,7 @@ dwarf2out_line (filename, line)
          /* Add the new entry at the end of the line_info_table.  */
          line_info
            = &separate_line_info_table[separate_line_info_table_in_use++];
-         line_info->dw_file_num = lookup_filename (filename);
+         line_info->dw_file_num = lookup_filename (&line_file_table, filename);
          line_info->dw_line_num = line;
          line_info->function = current_funcdef_number;
        }
@@ -10117,7 +11396,7 @@ dwarf2out_line (filename, line)
 
          /* Add the new entry at the end of the line_info_table.  */
          line_info = &line_info_table[line_info_table_in_use++];
-         line_info->dw_file_num = lookup_filename (filename);
+         line_info->dw_file_num = lookup_filename (&line_file_table, filename);
          line_info->dw_line_num = line;
        }
     }
@@ -10130,6 +11409,12 @@ void
 dwarf2out_start_source_file (filename)
      register const char *filename ATTRIBUTE_UNUSED;
 {
+  if (flag_eliminate_dwarf2_dups)
+    {
+      /* Record the beginning of the file for break_out_includes.  */
+      dw_die_ref bincl_die = new_die (DW_TAG_GNU_BINCL, comp_unit_die);
+      add_AT_string (bincl_die, DW_AT_name, filename);
+    }
 }
 
 /* Record the end of a source file, for later output
@@ -10138,6 +11423,11 @@ dwarf2out_start_source_file (filename)
 void
 dwarf2out_end_source_file ()
 {
+  if (flag_eliminate_dwarf2_dups)
+    {
+      /* Record the end of the file for break_out_includes.  */
+      new_die (DW_TAG_GNU_EINCL, comp_unit_die);
+    }
 }
 
 /* Called from check_newline in c-parse.y.  The `buffer' parameter contains
@@ -10178,12 +11468,8 @@ dwarf2out_init (asm_out_file, main_input_filename)
   /* Remember the name of the primary input file.  */
   primary_filename = main_input_filename;
 
-  /* Allocate the initial hunk of the file_table.  */
-  file_table = (char **) xcalloc (FILE_TABLE_INCREMENT, sizeof (char *));
-  file_table_allocated = FILE_TABLE_INCREMENT;
-
-  /* Skip the first entry - file numbers begin at 1.  */
-  file_table_in_use = 1;
+  init_file_table (&decl_file_table);
+  init_file_table (&line_file_table);
 
   /* Allocate the initial hunk of the decl_die_table.  */
   decl_die_table
@@ -10213,18 +11499,15 @@ dwarf2out_init (asm_out_file, main_input_filename)
   /* Zero-th entry is allocated, but unused */
   line_info_table_in_use = 1;
 
-  /* Generate the initial DIE for the .debug section.  Note that the (string) 
+  /* Generate the initial DIE for the .debug section.  Note that the (string)
      value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE
-     will (typically) be a relative pathname and that this pathname should be 
+     will (typically) be a relative pathname and that this pathname should be
      taken as being relative to the directory from which the compiler was
      invoked when the given (base) source file was compiled.  */
   comp_unit_die = gen_compile_unit_die (main_input_filename);
 
-  if (ggc_p)
-    {
-      VARRAY_RTX_INIT (used_rtx_varray, 32, "used_rtx_varray");
-      ggc_add_rtx_varray_root (&used_rtx_varray, 1);
-    }
+  VARRAY_RTX_INIT (used_rtx_varray, 32, "used_rtx_varray");
+  ggc_add_rtx_varray_root (&used_rtx_varray, 1);
 
   ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);
   ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label, ABBREV_SECTION_LABEL, 0);
@@ -10232,9 +11515,9 @@ dwarf2out_init (asm_out_file, main_input_filename)
     ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
   else
     strcpy (text_section_label, stripattributes (TEXT_SECTION));
-  ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label, 
+  ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label,
                               DEBUG_INFO_SECTION_LABEL, 0);
-  ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label, 
+  ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label,
                               DEBUG_LINE_SECTION_LABEL, 0);
 
   ASM_OUTPUT_SECTION (asm_out_file, ABBREV_SECTION);
@@ -10287,9 +11570,20 @@ dwarf2out_finish ()
      emit full debugging info for them.  */
   retry_incomplete_types ();
 
-  /* Traverse the DIE's, reverse their lists of attributes and children,
-     and add add sibling attributes to those DIE's that have children.  */
+  /* We need to reverse all the dies before break_out_includes, or
+     we'll see the end of an include file before the beginning.  */
+  reverse_all_dies (comp_unit_die);
+
+  /* Generate separate CUs for each of the include files we've seen.
+     They will go into limbo_die_list.  */
+  if (flag_eliminate_dwarf2_dups)
+    break_out_includes (comp_unit_die);
+
+  /* Traverse the DIE's and add add sibling attributes to those DIE's
+     that have children.  */
   add_sibling_attributes (comp_unit_die);
+  for (node = limbo_die_list; node; node = node->next)
+    add_sibling_attributes (node->die);
 
   /* Output a terminator label for the .text section.  */
   fputc ('\n', asm_out_file);
@@ -10335,22 +11629,17 @@ dwarf2out_finish ()
     add_AT_unsigned (die, DW_AT_macro_info, 0);
 #endif
 
+  /* Output all of the compilation units.  We put the main one last so that
+     the offsets are available to output_pubnames.  */
+  for (node = limbo_die_list; node; node = node->next)
+    output_comp_unit (node->die);
+  output_comp_unit (comp_unit_die);
+
   /* Output the abbreviation table.  */
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_SECTION (asm_out_file, ABBREV_SECTION);
-  build_abbrev_table (comp_unit_die);
   output_abbrev_section ();
 
-  /* Initialize the beginning DIE offset - and calculate sizes/offsets.   */
-  next_die_offset = DWARF_COMPILE_UNIT_HEADER_SIZE;
-  calc_die_sizes (comp_unit_die);
-
-  /* Output debugging information.  */
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_SECTION (asm_out_file, DEBUG_INFO_SECTION);
-  output_compilation_unit_header ();
-  output_die (comp_unit_die);
-
   if (pubname_table_in_use)
     {
       /* Output public names table.  */