* config/sparc/nm-linux.h: Include config/nm-linux.h.
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index 83679fe57785c9375d50a03c3f7d914699105488..3025bbdcb042bdf8207391dbc10263514c323ee3 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "defs.h"
 #include "bfd.h"
-#include "elf-bfd.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "symfile.h"
@@ -546,15 +545,6 @@ static struct complaint dwarf2_unsupported_const_value_attr =
    whatever scope is currently getting read. */
 static int address_size;
 
-/* Some elf32 object file formats while linked for a 32 bit address
-   space contain debug information that has assumed 64 bit
-   addresses. Eg 64 bit MIPS target produced by GCC/GAS/LD where the
-   symbol table contains 32bit address values while its .debug_info
-   section contains 64 bit address values.
-   ADDRESS_SIGNIFICANT_SIZE specifies the number significant bits in
-   the ADDRESS_SIZE bytes read from the file */
-static int address_significant_size;
-
 /* Externals references.  */
 extern int info_verbose;       /* From main.c; nonzero => verbose */
 
@@ -621,6 +611,8 @@ static void set_cu_language PARAMS ((unsigned int));
 static struct attribute *dwarf_attr PARAMS ((struct die_info *,
                                             unsigned int));
 
+static int die_is_declaration (struct die_info *);
+
 static void dwarf_decode_lines PARAMS ((unsigned int, char *, bfd *));
 
 static void dwarf2_start_subfile PARAMS ((char *, char *));
@@ -716,6 +708,8 @@ struct die_info *read_comp_unit PARAMS ((char *, bfd *));
 
 static void free_die_list PARAMS ((struct die_info *));
 
+static struct cleanup *make_cleanup_free_die_list (struct die_info *);
+
 static void process_die PARAMS ((struct die_info *, struct objfile *));
 
 static char *dwarf2_linkage_name PARAMS ((struct die_info *));
@@ -935,9 +929,6 @@ dwarf2_build_psymtabs_hard (objfile, mainline)
   int comp_unit_has_pc_info;
   CORE_ADDR lowpc, highpc;
 
-  /* Number of bytes of any addresses that are signficant */
-  address_significant_size = get_elf_backend_data (abfd)->s->arch_size / 8;
-
   info_ptr = dwarf_info_buffer;
   abbrev_ptr = dwarf_abbrev_buffer;
 
@@ -978,13 +969,6 @@ dwarf2_build_psymtabs_hard (objfile, mainline)
                 (long) (beg_of_comp_unit - dwarf_info_buffer));
          return;
        }
-      if (address_size < address_significant_size)
-       {
-         error ("Dwarf Error: bad address size (%ld) in compilation unit header (offset 0x%lx + 11).",
-                (long) cu_header.addr_size,
-                (long) (beg_of_comp_unit - dwarf_info_buffer));
-       }
-
       /* Read the abbrevs for this compilation unit into a table */
       dwarf2_read_abbrevs (abfd, cu_header.abbrev_offset);
       make_cleanup (dwarf2_empty_abbrev_table, NULL);
@@ -1340,7 +1324,7 @@ psymtab_to_symtab_1 (pst)
 
   dies = read_comp_unit (info_ptr, abfd);
 
-  make_cleanup ((make_cleanup_func) free_die_list, dies);
+  make_cleanup_free_die_list (dies);
 
   /* Do line number decoding in read_file_scope () */
   process_die (dies, objfile);
@@ -2016,8 +2000,7 @@ dwarf2_add_member_fn (fip, die, type, objfile)
                      (fip->nfnfields + DW_FIELD_ALLOC_CHUNK)
                      * sizeof (struct fnfieldlist));
          if (fip->nfnfields == 0)
-           make_cleanup ((make_cleanup_func) free_current_contents,
-                         &fip->fnfieldlists);
+           make_cleanup (free_current_contents, &fip->fnfieldlists);
        }
       flp = &fip->fnfieldlists[fip->nfnfields];
       flp->name = fieldname;
@@ -2202,7 +2185,7 @@ read_structure_scope (die, objfile)
      type within the structure itself. */
   die->type = type;
 
-  if (die->has_children)
+  if (die->has_children && ! die_is_declaration (die))
     {
       struct field_info fi;
       struct die_info *child_die;
@@ -2524,8 +2507,7 @@ read_array_type (die, objfile)
                xrealloc (range_types, (ndim + DW_FIELD_ALLOC_CHUNK)
                          * sizeof (struct type *));
              if (ndim == 0)
-               make_cleanup ((make_cleanup_func) free_current_contents,
-                             &range_types);
+               make_cleanup (free_current_contents, &range_types);
            }
          range_types[ndim++] = create_range_type (NULL, index_type, low, high);
        }
@@ -2976,6 +2958,19 @@ free_die_list (dies)
     }
 }
 
+static void
+do_free_die_list_cleanup (void *dies)
+{
+  free_die_list (dies);
+}
+
+static struct cleanup *
+make_cleanup_free_die_list (struct die_info *dies)
+{
+  return make_cleanup (do_free_die_list_cleanup, dies);
+}
+
+
 /* Read the contents of the section at OFFSET and of size SIZE from the
    object file specified by OBJFILE into the psymbol_obstack and return it.  */
 
@@ -3485,6 +3480,9 @@ read_address (abfd, buf)
 
   switch (address_size)
     {
+    case 2:
+      retval = bfd_get_16 (abfd, (bfd_byte *) buf);
+      break;
     case 4:
       retval = bfd_get_32 (abfd, (bfd_byte *) buf);
       break;
@@ -3495,17 +3493,8 @@ read_address (abfd, buf)
       /* *THE* alternative is 8, right? */
       abort ();
     }
-  /* If the address being read is larger than the address that is
-     applicable for the object file format then mask it down to the
-     correct size.  Take care to avoid unnecessary shift or shift
-     overflow */
-  if (address_size > address_significant_size
-      && address_significant_size < sizeof (CORE_ADDR))
-    {
-      CORE_ADDR mask = ((CORE_ADDR) 0) - 1;
-      retval &= ~(mask << (address_significant_size * 8));
-    }
-  return retval;
+
+ return retval;
 }
 
 static char *
@@ -3700,6 +3689,13 @@ dwarf_attr (die, name)
   return NULL;
 }
 
+static int
+die_is_declaration (struct die_info *die)
+{
+  return (dwarf_attr (die, DW_AT_declaration)
+         && ! dwarf_attr (die, DW_AT_specification));
+}
+
 /* Decode the line number information for the compilation unit whose
    line number info is at OFFSET in the .debug_line section.
    The compilation directory of the file is passed in COMP_DIR.  */
@@ -3777,8 +3773,7 @@ dwarf_decode_lines (offset, comp_dir, abfd)
   line_ptr += 1;
   lh.standard_opcode_lengths = (unsigned char *)
     xmalloc (lh.opcode_base * sizeof (unsigned char));
-  back_to = make_cleanup ((make_cleanup_func) free_current_contents,
-                         &lh.standard_opcode_lengths);
+  back_to = make_cleanup (free_current_contents, &lh.standard_opcode_lengths);
 
   lh.standard_opcode_lengths[0] = 1;
   for (i = 1; i < lh.opcode_base; ++i)
@@ -3797,7 +3792,7 @@ dwarf_decode_lines (offset, comp_dir, abfd)
            xrealloc (dirs.dirs,
                      (dirs.num_dirs + DIR_ALLOC_CHUNK) * sizeof (char *));
          if (dirs.num_dirs == 0)
-           make_cleanup ((make_cleanup_func) free_current_contents, &dirs.dirs);
+           make_cleanup (free_current_contents, &dirs.dirs);
        }
       dirs.dirs[dirs.num_dirs++] = cur_dir;
     }
@@ -3814,8 +3809,7 @@ dwarf_decode_lines (offset, comp_dir, abfd)
                      (files.num_files + FILE_ALLOC_CHUNK)
                      * sizeof (struct fileinfo));
          if (files.num_files == 0)
-           make_cleanup ((make_cleanup_func) free_current_contents,
-                         &files.files);
+           make_cleanup (free_current_contents, &files.files);
        }
       files.files[files.num_files].name = cur_file;
       files.files[files.num_files].dir =
@@ -3890,8 +3884,7 @@ dwarf_decode_lines (offset, comp_dir, abfd)
                                  (files.num_files + FILE_ALLOC_CHUNK)
                                  * sizeof (struct fileinfo));
                      if (files.num_files == 0)
-                       make_cleanup ((make_cleanup_func) free_current_contents,
-                                     &files.files);
+                       make_cleanup (free_current_contents, &files.files);
                    }
                  files.files[files.num_files].name = cur_file;
                  files.files[files.num_files].dir =
@@ -4363,7 +4356,7 @@ dwarf2_const_value_data (struct attribute *attr,
       if (TYPE_UNSIGNED (SYMBOL_TYPE (sym)))
        l &= ((LONGEST) 1 << bits) - 1;
       else
-       l = (l << (sizeof (l) - bits)) >> (sizeof (l) - bits);
+       l = (l << (sizeof (l) * 8 - bits)) >> (sizeof (l) * 8 - bits);
     }
 
   SYMBOL_VALUE (sym) = l;
@@ -5749,6 +5742,14 @@ decode_locdesc (blk, objfile)
          i += bytes_read;
          break;
 
+       case DW_OP_bregx:
+         offreg = 1;
+         basereg = read_unsigned_leb128 (NULL, (data + i), &bytes_read);
+         i += bytes_read;
+         stack[++stacki] = read_signed_leb128 (NULL, (data + i), &bytes_read);
+         i += bytes_read;
+         break;
+
        case DW_OP_fbreg:
          stack[++stacki] = read_signed_leb128 (NULL, (data + i), &bytes_read);
          i += bytes_read;
This page took 0.027609 seconds and 4 git commands to generate.