[gdb/symtab] Fix name lookup in dw2_map_matching_symbols
[deliverable/binutils-gdb.git] / gdb / dwarf2 / comp-unit.c
index 03e804b7086b72f705e035edb4c6408905034e65..7ddc893aac6287d4f9a88e454e75b66eed96e9ef 100644 (file)
@@ -129,9 +129,8 @@ read_comp_unit_head (struct comp_unit_head *cu_header,
       cu_header->addr_size = read_1_byte (abfd, info_ptr);
       info_ptr += 1;
     }
-  cu_header->abbrev_sect_off = (sect_offset) read_offset (abfd, info_ptr,
-                                                         cu_header,
-                                                         &bytes_read);
+  cu_header->abbrev_sect_off
+    = (sect_offset) cu_header->read_offset (abfd, info_ptr, &bytes_read);
   info_ptr += bytes_read;
   if (cu_header->version < 5)
     {
@@ -157,7 +156,7 @@ read_comp_unit_head (struct comp_unit_head *cu_header,
   if (section_kind == rcuh_kind::TYPE)
     {
       LONGEST type_offset;
-      type_offset = read_offset (abfd, info_ptr, cu_header, &bytes_read);
+      type_offset = cu_header->read_offset (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       cu_header->type_cu_offset_in_tu = (cu_offset) type_offset;
       if (to_underlying (cu_header->type_cu_offset_in_tu) != type_offset)
@@ -174,7 +173,7 @@ read_comp_unit_head (struct comp_unit_head *cu_header,
    Perform various error checking on the header.  */
 
 static void
-error_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile,
+error_check_comp_unit_head (dwarf2_per_objfile *per_objfile,
                            struct comp_unit_head *header,
                            struct dwarf2_section_info *section,
                            struct dwarf2_section_info *abbrev_section)
@@ -182,7 +181,7 @@ error_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile,
   const char *filename = section->get_file_name ();
 
   if (to_underlying (header->abbrev_sect_off)
-      >= abbrev_section->get_size (dwarf2_per_objfile->objfile))
+      >= abbrev_section->get_size (per_objfile->objfile))
     error (_("Dwarf Error: bad offset (%s) in compilation unit header "
           "(offset %s + 6) [in module %s]"),
           sect_offset_str (header->abbrev_sect_off),
@@ -202,7 +201,7 @@ error_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile,
 /* See comp-unit.h.  */
 
 const gdb_byte *
-read_and_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile,
+read_and_check_comp_unit_head (dwarf2_per_objfile *per_objfile,
                               struct comp_unit_head *header,
                               struct dwarf2_section_info *section,
                               struct dwarf2_section_info *abbrev_section,
@@ -217,21 +216,57 @@ read_and_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile,
 
   header->first_die_cu_offset = (cu_offset) (info_ptr - beg_of_comp_unit);
 
-  error_check_comp_unit_head (dwarf2_per_objfile, header, section,
-                             abbrev_section);
+  error_check_comp_unit_head (per_objfile, header, section, abbrev_section);
 
   return info_ptr;
 }
 
-/* See comp-unit.h.  */
-
-LONGEST
-read_offset (bfd *abfd, const gdb_byte *buf,
-            const struct comp_unit_head *cu_header,
-             unsigned int *bytes_read)
+CORE_ADDR
+comp_unit_head::read_address (bfd *abfd, const gdb_byte *buf,
+                             unsigned int *bytes_read) const
 {
-  LONGEST offset = read_offset (abfd, buf, cu_header->offset_size);
+  CORE_ADDR retval = 0;
+
+  if (signed_addr_p)
+    {
+      switch (addr_size)
+       {
+       case 2:
+         retval = bfd_get_signed_16 (abfd, buf);
+         break;
+       case 4:
+         retval = bfd_get_signed_32 (abfd, buf);
+         break;
+       case 8:
+         retval = bfd_get_signed_64 (abfd, buf);
+         break;
+       default:
+         internal_error (__FILE__, __LINE__,
+                         _("read_address: bad switch, signed [in module %s]"),
+                         bfd_get_filename (abfd));
+       }
+    }
+  else
+    {
+      switch (addr_size)
+       {
+       case 2:
+         retval = bfd_get_16 (abfd, buf);
+         break;
+       case 4:
+         retval = bfd_get_32 (abfd, buf);
+         break;
+       case 8:
+         retval = bfd_get_64 (abfd, buf);
+         break;
+       default:
+         internal_error (__FILE__, __LINE__,
+                         _("read_address: bad switch, "
+                           "unsigned [in module %s]"),
+                         bfd_get_filename (abfd));
+       }
+    }
 
-  *bytes_read = cu_header->offset_size;
-  return offset;
+  *bytes_read = addr_size;
+  return retval;
 }
This page took 0.024942 seconds and 4 git commands to generate.