Thu May 21 13:14:25 1998 John Metzler <jmetzler@cygnus.com>
[deliverable/binutils-gdb.git] / gdb / solib.c
index b09b140af8b0086b265c40b4bf756ee48b8a2f88..3f6e73002358c6f410de960e056c7eeb866dd791 100644 (file)
@@ -186,8 +186,8 @@ first_link_map_member PARAMS ((void));
 static CORE_ADDR
 locate_base PARAMS ((void));
 
-static void
-solib_map_sections PARAMS ((struct so_list *));
+static int
+solib_map_sections PARAMS ((char *));
 
 #ifdef SVR4_SHARED_LIBS
 
@@ -224,7 +224,7 @@ LOCAL FUNCTION
 
 SYNOPSIS
 
-       static void solib_map_sections (struct so_list *so)
+       static int solib_map_sections (struct so_list *so)
 
 DESCRIPTION
 
@@ -243,10 +243,11 @@ FIXMES
        expansion stuff?).
  */
 
-static void
-solib_map_sections (so)
-     struct so_list *so;
+static int
+solib_map_sections (arg)
+     char *arg;
 {
+  struct so_list *so = (struct so_list *) arg; /* catch_errors bogon */
   char *filename;
   char *scratch_pathname;
   int scratch_chan;
@@ -343,6 +344,8 @@ solib_map_sections (so)
 
   /* Free the file names, close the file now.  */
   do_cleanups (old_chain);
+
+  return (1);
 }
 
 #ifndef SVR4_SHARED_LIBS
@@ -688,8 +691,7 @@ elf_locate_base ()
   /* Find the DT_DEBUG entry in the the .dynamic section.
      For mips elf we look for DT_MIPS_RLD_MAP, mips elf apparently has
      no DT_DEBUG entries.  */
-  /* FIXME: In lack of a 64 bit ELF ABI the following code assumes
-     a 32 bit ELF ABI target.  */
+#ifndef TARGET_ELF64
   for (bufend = buf + dyninfo_sect_size;
        buf < bufend;
        buf += sizeof (Elf32_External_Dyn))
@@ -720,6 +722,25 @@ elf_locate_base ()
        }
 #endif
     }
+#else /* ELF64 */
+  for (bufend = buf + dyninfo_sect_size;
+       buf < bufend;
+       buf += sizeof (Elf64_External_Dyn))
+    {
+      Elf64_External_Dyn *x_dynp = (Elf64_External_Dyn *)buf;
+      long dyn_tag;
+      CORE_ADDR dyn_ptr;
+
+      dyn_tag = bfd_h_get_64 (exec_bfd, (bfd_byte *) x_dynp->d_tag);
+      if (dyn_tag == DT_NULL)
+       break;
+      else if (dyn_tag == DT_DEBUG)
+       {
+         dyn_ptr = bfd_h_get_64 (exec_bfd, (bfd_byte *) x_dynp->d_un.d_ptr);
+         return dyn_ptr;
+       }
+    }
+#endif
 
   /* DT_DEBUG entry not found.  */
   return 0;
@@ -968,12 +989,17 @@ find_solib (so_list_ptr)
          target_read_string ((CORE_ADDR) LM_NAME (new), &buffer,
                              MAX_PATH_SIZE - 1, &errcode);
          if (errcode != 0)
-           error ("find_solib: Can't read pathname for load map: %s\n",
-                  safe_strerror (errcode));
+           {
+             warning ("find_solib: Can't read pathname for load map: %s\n",
+                      safe_strerror (errcode));
+             return (so_list_next);
+           }
          strncpy (new -> so_name, buffer, MAX_PATH_SIZE - 1);
          new -> so_name[MAX_PATH_SIZE - 1] = '\0';
          free (buffer);
-         solib_map_sections (new);
+         catch_errors (solib_map_sections, (char *) new,
+                       "Error while mapping shared library sections:\n",
+                       RETURN_MASK_ALL);
        }      
     }
   return (so_list_next);
@@ -990,7 +1016,7 @@ symbol_add_stub (arg)
 
   if (so -> textsection)
     text_addr = so -> textsection -> addr;
-  else
+  else if (so -> abfd != NULL)
     {
       asection *lowest_sect;
 
@@ -1190,30 +1216,41 @@ info_sharedlibrary_command (ignore, from_tty)
 {
   register struct so_list *so = NULL;          /* link map state variable */
   int header_done = 0;
-  
+  int addr_width;
+  char *addr_fmt;
+
   if (exec_bfd == NULL)
     {
       printf_unfiltered ("No exec file.\n");
       return;
     }
+
+#ifndef TARGET_ELF64
+  addr_width = 8+4;
+  addr_fmt = "08l";
+#else
+  addr_width = 16+4;
+  addr_fmt = "016l";
+#endif
+
   while ((so = find_solib (so)) != NULL)
     {
       if (so -> so_name[0])
        {
          if (!header_done)
            {
-             printf_unfiltered("%-12s%-12s%-12s%s\n", "From", "To", "Syms Read",
-                    "Shared Object Library");
+             printf_unfiltered("%-*s%-*s%-12s%s\n", addr_width, "From",
+                               addr_width, "To", "Syms Read",
+                               "Shared Object Library");
              header_done++;
            }
-         /* FIXME-32x64: need print_address_numeric with field width or
-            some such.  */
-         printf_unfiltered ("%-12s",
+
+         printf_unfiltered ("%-*s", addr_width,
                  local_hex_string_custom ((unsigned long) LM_ADDR (so),
-                                          "08l"));
-         printf_unfiltered ("%-12s",
+                                          addr_fmt));
+         printf_unfiltered ("%-*s", addr_width,
                  local_hex_string_custom ((unsigned long) so -> lmend,
-                                          "08l"));
+                                          addr_fmt));
          printf_unfiltered ("%-12s", so -> symbols_loaded ? "Yes" : "No");
          printf_unfiltered ("%s\n",  so -> so_name);
        }
@@ -1515,7 +1552,7 @@ enable_break ()
 
         This address is stored on the stack.  However, I've been unable
         to find any magic formula to find it for Solaris (appears to
-        be trivial on Linux).  Therefore, we have to try an alternate
+        be trivial on GNU/Linux).  Therefore, we have to try an alternate
         mechanism to find the dynamic linker's base address.  */
       tmp_bfd = bfd_openr (buf, gnutarget);
       if (tmp_bfd == NULL)
@@ -1573,9 +1610,7 @@ enable_break ()
       /* For whatever reason we couldn't set a breakpoint in the dynamic
         linker.  Warn and drop into the old code.  */
 bkpt_at_symbol:
-      warning ("Unable to find dynamic linker breakpoint function.");
-      warning ("GDB will be unable to debug shared library initializers");
-      warning ("and track explicitly loaded dynamic code.");
+      warning ("Unable to find dynamic linker breakpoint function.\nGDB will be unable to debug shared library initializers\nand track explicitly loaded dynamic code.");
     }
 #endif
 
@@ -1676,8 +1711,8 @@ solib_create_inferior_hook()
       return;
     }
 
-#ifndef SVR4_SHARED_LIBS
-  /* Only SunOS needs the loop below, other systems should be using the
+#if !defined(SVR4_SHARED_LIBS) || defined(_SCO_DS)
+  /* SCO and SunOS need the loop below, other systems should be using the
      special shared library breakpoints and the shared library breakpoint
      service routine.
 
@@ -1696,7 +1731,8 @@ solib_create_inferior_hook()
     }
   while (stop_signal != TARGET_SIGNAL_TRAP);
   stop_soon_quietly = 0;
-  
+
+#if !defined(_SCO_DS)
   /* We are now either at the "mapping complete" breakpoint (or somewhere
      else, a condition we aren't prepared to deal with anyway), so adjust
      the PC as necessary after a breakpoint, disable the breakpoint, and
@@ -1715,6 +1751,7 @@ solib_create_inferior_hook()
 
   if (auto_solib_add)
     solib_add ((char *) 0, 0, (struct target_ops *) 0);
+#endif /* ! _SCO_DS */
 #endif
 }
 
This page took 0.026213 seconds and 4 git commands to generate.