Don't update target_dcache if it is not initialized
[deliverable/binutils-gdb.git] / gdb / solib-aix.c
index f891af0293c29d9ef9e69ab0773bd2510a52ab0c..8fc516ab4d7d4869fc3faf75350ffd999dade36b 100644 (file)
@@ -141,6 +141,13 @@ solib_aix_parse_libraries (const char *library)
   return NULL;
 }
 
+/* Dummy implementation if XML support is not compiled in.  */
+
+static void
+solib_aix_free_library_list (void *p)
+{
+}
+
 #else /* HAVE_LIBEXPAT */
 
 #include "xml-support.h"
@@ -179,7 +186,7 @@ library_list_start_library (struct gdb_xml_parser *parser,
   VEC_safe_push (lm_info_p, *list, item);
 }
 
-/* Handle the start of a <library-list> element.  */
+/* Handle the start of a <library-list-aix> element.  */
 
 static void
 library_list_start_list (struct gdb_xml_parser *parser,
@@ -213,7 +220,7 @@ solib_aix_free_library_list (void *p)
 }
 
 /* The allowed elements and attributes for an AIX library list
-   described in XML format.  The root element is a <library-list>.  */
+   described in XML format.  The root element is a <library-list-aix>.  */
 
 static const struct gdb_xml_attribute library_attributes[] =
 {
@@ -242,7 +249,7 @@ static const struct gdb_xml_attribute library_list_attributes[] =
 
 static const struct gdb_xml_element library_list_elements[] =
 {
-  { "library-list", library_list_attributes, library_list_children,
+  { "library-list-aix", library_list_attributes, library_list_children,
     GDB_XML_EF_NONE, library_list_start_list, NULL },
   { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
 };
@@ -383,8 +390,8 @@ static void
 solib_aix_relocate_section_addresses (struct so_list *so,
                                      struct target_section *sec)
 {
-  bfd *abfd = sec->bfd;
   struct bfd_section *bfd_sect = sec->the_bfd_section;
+  bfd *abfd = bfd_sect->owner;
   const char *section_name = bfd_section_name (abfd, bfd_sect);
   struct lm_info *info = so->lm_info;
 
@@ -404,23 +411,27 @@ solib_aix_relocate_section_addresses (struct so_list *so,
     }
   else if (strcmp (section_name, ".bss") == 0)
     {
-      sec->addr = bfd_section_vma (abfd, bfd_sect) + info->data_addr;
+      /* The information provided by the loader does not include
+        the address of the .bss section, but we know that it gets
+        relocated by the same offset as the .data section.  So,
+        compute the relocation offset for the .data section, and
+        apply it to the .bss section as well.  If the .data section
+        is not defined (which seems highly unlikely), do our best
+        by assuming no relocation.  */
+      struct bfd_section *data_sect
+       = bfd_get_section_by_name (abfd, ".data");
+      CORE_ADDR data_offset = 0;
+
+      if (data_sect != NULL)
+       data_offset = info->data_addr - bfd_section_vma (abfd, data_sect);
+
+      sec->addr = bfd_section_vma (abfd, bfd_sect) + data_offset;
       sec->addr += solib_aix_bss_data_overlap (abfd);
       sec->endaddr = sec->addr + bfd_section_size (abfd, bfd_sect);
     }
   else
     {
       /* All other sections should not be relocated.  */
-      /* FIXME: GDB complains that the .loader section sometimes
-        overlaps with other sections (Eg: the .data section).
-        As far as I can tell, the loader section had the LOAD flag
-        set, but not the RELOC.  So it should not be relocated.
-        There seems to be a problem there, and maybe it has to do
-        with setting sec->addr to 0 (when the vma is indeed 0).
-        But even if there wasn't, the problem then becomes the fact
-        that many shared objects inside shared libraries have
-        a .loader section whose vma is 0, thus also triggering
-        an overlap warning.  */
       sec->addr = bfd_section_vma (abfd, bfd_sect);
       sec->endaddr = sec->addr + bfd_section_size (abfd, bfd_sect);
     }
@@ -636,7 +647,7 @@ solib_aix_bfd_open (char *pathname)
   int filename_len;
   char *member_name;
   bfd *archive_bfd, *object_bfd;
-  struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
+  struct cleanup *cleanup;
 
   if (pathname[path_len - 1] != ')')
     return solib_bfd_open (pathname);
@@ -654,7 +665,7 @@ solib_aix_bfd_open (char *pathname)
   filename_len = sep - pathname;
 
   filename = xstrprintf ("%.*s", filename_len, pathname);
-  make_cleanup (xfree, filename);
+  cleanup = make_cleanup (xfree, filename);
   member_name = xstrprintf ("%.*s", path_len - filename_len - 2, sep + 1);
   make_cleanup (xfree, member_name);
 
@@ -754,7 +765,7 @@ solib_aix_get_toc_value (CORE_ADDR pc)
   if (data_osect == NULL)
     error (_("unable to find TOC entry for pc %s "
             "(%s has no data section)"),
-          core_addr_to_string (pc), pc_osect->objfile->name);
+          core_addr_to_string (pc), objfile_name (pc_osect->objfile));
 
   result = (obj_section_addr (data_osect)
            + xcoff_get_toc_offset (pc_osect->objfile));
This page took 0.025351 seconds and 4 git commands to generate.