*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / solib-pa64.c
index 9f541049538518ab0bfb5aa06da34e011f1fb1c0..bccb52d695a1a49ee5a8a96dda313f55c2975662 100644 (file)
@@ -1,6 +1,6 @@
 /* Handle PA64 shared libraries for GDB, the GNU Debugger.
 
-   Copyright 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2007 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -16,8 +16,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  
    
    HP in their infinite stupidity choose not to use standard ELF dynamic
    linker interfaces.  They also choose not to make their ELF dymamic
@@ -31,9 +31,6 @@
    same functionality in all their libraries!  */
 
 #include "defs.h"
-#include <dlfcn.h>
-#include <elf.h>
-#include <elf_hp.h>
 #include "symtab.h"
 #include "bfd.h"
 #include "symfile.h"
 /* If we are building for a SOM-only target, then we don't need this.  */
 #ifndef PA_SOM_ONLY
 
+/* FIXME: kettenis/20041213: These includes should be eliminated.  */
+#include <dlfcn.h>
+#include <elf.h>
+#include <elf_hp.h>
+
 struct lm_info {
   struct load_module_desc desc;
   CORE_ADDR desc_addr;
@@ -79,6 +81,23 @@ static void
 pa64_relocate_section_addresses (struct so_list *so,
                                 struct section_table *sec)
 {
+  asection *asec = sec->the_bfd_section;
+  CORE_ADDR load_offset;
+
+  /* Relocate all the sections based on where they got loaded.  */
+
+  load_offset = bfd_section_vma (so->abfd, asec) - asec->filepos;
+
+  if (asec->flags & SEC_CODE)
+    {
+      sec->addr += so->lm_info->desc.text_base - load_offset;
+      sec->endaddr += so->lm_info->desc.text_base - load_offset;
+    }
+  else if (asec->flags & SEC_DATA)
+    {
+      sec->addr += so->lm_info->desc.data_base - load_offset;
+      sec->endaddr += so->lm_info->desc.data_base - load_offset;
+    }
 }
 
 static void
@@ -120,7 +139,7 @@ read_dld_descriptor (void)
   if (!dld_cache.is_valid) 
     {
       if (symfile_objfile == NULL)
-       error ("No object file symbols.");
+       error (_("No object file symbols."));
 
       dyninfo_sect = bfd_get_section_by_name (symfile_objfile->obfd, 
                                              ".dynamic");
@@ -130,7 +149,7 @@ read_dld_descriptor (void)
        }
 
       if (!read_dynamic_info (dyninfo_sect, &dld_cache))
-       error ("Unable to read in .dynamic section information.");
+       error (_("Unable to read in .dynamic section information."));
     }
 
   /* Read the load map pointer.  */
@@ -139,7 +158,7 @@ read_dld_descriptor (void)
                          sizeof (dld_cache.load_map))
       != 0)
     {
-      error ("Error while reading in load map pointer.");
+      error (_("Error while reading in load map pointer."));
     }
 
   /* Read in the dld load module descriptor */
@@ -151,7 +170,7 @@ read_dld_descriptor (void)
                    dld_cache.load_map)
       == 0)
     {
-      error ("Error trying to get information about dynamic linker.");
+      error (_("Error trying to get information about dynamic linker."));
     }
 
   /* Indicate that we have loaded the dld descriptor.  */
@@ -209,7 +228,7 @@ read_dynamic_info (asection *dyninfo_sect, dld_cache_t *dld_cache_p)
                                  sizeof (dld_cache_p->dld_flags))
              != 0)
            {
-             error ("Error while reading in .dynamic section of the program.");
+             error (_("Error while reading in .dynamic section of the program."));
            }
        }
       else if (dyn_tag == DT_HP_LOAD_MAP)
@@ -222,7 +241,7 @@ read_dynamic_info (asection *dyninfo_sect, dld_cache_t *dld_cache_p)
                                  sizeof (dld_cache_p->load_map_addr))
              != 0)
            {
-             error ("Error while reading in .dynamic section of the program.");
+             error (_("Error while reading in .dynamic section of the program."));
            }
        }
       else 
@@ -336,7 +355,7 @@ pa64_solib_create_inferior_hook (void)
 
   /* Read in the .dynamic section.  */
   if (! read_dynamic_info (shlib_info, &dld_cache))
-    error ("Unable to read the .dynamic section.");
+    error (_("Unable to read the .dynamic section."));
 
   /* Turn on the flags we care about.  */
   dld_cache.dld_flags |= DT_HP_DEBUG_PRIVATE;
@@ -345,7 +364,7 @@ pa64_solib_create_inferior_hook (void)
                                (char *) &dld_cache.dld_flags,
                                sizeof (dld_cache.dld_flags));
   if (status != 0)
-    error ("Unable to modify dynamic linker flags.");
+    error (_("Unable to modify dynamic linker flags."));
 
   /* Now we have to create a shared library breakpoint in the dynamic
      linker.  This can be somewhat tricky since the symbol is inside
@@ -382,7 +401,7 @@ pa64_solib_create_inferior_hook (void)
       /* Make sure the dynamic linker's really a useful object.  */
       if (!bfd_check_format (tmp_bfd, bfd_object))
        {
-         warning ("Unable to grok dynamic linker %s as an object file", buf);
+         warning (_("Unable to grok dynamic linker %s as an object file"), buf);
          bfd_close (tmp_bfd);
          return;
        }
@@ -434,17 +453,20 @@ pa64_current_sos (void)
 
   /* If the libraries were not mapped private, warn the user.  */
   if ((dld_cache.dld_flags & DT_HP_DEBUG_PRIVATE) == 0)
-    warning ("The shared libraries were not privately mapped; setting a\n"
+    warning (_("The shared libraries were not privately mapped; setting a\n"
             "breakpoint in a shared library will not work until you rerun "
-            "the program.\n");
+            "the program.\n"));
 
-  for (dll_index = 1; ; dll_index++)
+  for (dll_index = -1; ; dll_index++)
     {
       struct load_module_desc dll_desc;
       char *dll_path;
       struct so_list *new;
       struct cleanup *old_chain;
 
+      if (dll_index == 0)
+        continue;
+
       /* Read in the load module descriptor.  */
       if (dlgetmodinfo (dll_index, &dll_desc, sizeof (dll_desc),
                        pa64_target_read_memory, 0, dld_cache.load_map)
@@ -456,9 +478,6 @@ pa64_current_sos (void)
                            pa64_target_read_memory,
                            0, dld_cache.load_map);
 
-      if (dll_path == NULL)
-        dll_path = "";
-
       new = (struct so_list *) xmalloc (sizeof (struct so_list));
       memset (new, 0, sizeof (struct so_list));
       new->lm_info = (struct lm_info *) xmalloc (sizeof (struct lm_info));
@@ -564,9 +583,9 @@ pa64_solib_get_got_by_pc (CORE_ADDR addr)
          && ((so_list->lm_info->desc.text_base
               + so_list->lm_info->desc.text_size)
              > addr))
-       {
+        {
          got_value = so_list->lm_info->desc.linkage_ptr;
-         break;
+         break;
        }
       so_list = so_list->next;
     }
@@ -582,9 +601,7 @@ pa64_solib_thread_start_addr (struct so_list *so)
 
 
 /* Return the address of the handle of the shared library in which ADDR
-   belongs.  If ADDR isn't in any known shared library, return zero. 
-
-   This function is used in hppa_fix_call_dummy in hppa-tdep.c.  */
+   belongs.  If ADDR isn't in any known shared library, return zero.  */
 
 static CORE_ADDR
 pa64_solib_get_solib_by_pc (CORE_ADDR addr)
@@ -607,6 +624,22 @@ pa64_solib_get_solib_by_pc (CORE_ADDR addr)
   return retval;
 }
 
+/* pa64 libraries do not seem to set the section offsets in a standard (i.e. 
+   SVr4) way; the text section offset stored in the file doesn't correspond
+   to the place where the library is actually loaded into memory.  Instead,
+   we rely on the dll descriptor to tell us where things were loaded.  */
+static CORE_ADDR
+pa64_solib_get_text_base (struct objfile *objfile)
+{
+  struct so_list *so;
+
+  for (so = master_so_list (); so; so = so->next)
+    if (so->objfile == objfile)
+      return so->lm_info->desc.text_base;
+  
+  return 0;
+}
+
 static struct target_so_ops pa64_so_ops;
 
 extern initialize_file_ftype _initialize_pa64_solib; /* -Wmissing-prototypes */
@@ -633,6 +666,7 @@ void pa64_solib_select (struct gdbarch_tdep *tdep)
   tdep->solib_thread_start_addr = pa64_solib_thread_start_addr;
   tdep->solib_get_got_by_pc = pa64_solib_get_got_by_pc;
   tdep->solib_get_solib_by_pc = pa64_solib_get_solib_by_pc;
+  tdep->solib_get_text_base = pa64_solib_get_text_base;
 }
 
 #else /* PA_SOM_ONLY */
@@ -648,6 +682,6 @@ void pa64_solib_select (struct gdbarch_tdep *tdep)
 {
   /* For a SOM-only target, there is no pa64 solib support.  This is needed
      for hppa-hpux-tdep.c to build.  */
-  error ("Cannot select pa64 solib support for this configuration.\n");
+  error (_("Cannot select pa64 solib support for this configuration."));
 }
 #endif
This page took 0.026513 seconds and 4 git commands to generate.