Removed superflous code.
[deliverable/binutils-gdb.git] / gdb / osfsolib.c
index cdc2de9efc1397bcffdab17a035a5d440290e5fd..21b423b956529119048e5eb742d289fffb38b52a 100644 (file)
@@ -1,5 +1,5 @@
 /* Handle OSF/1 shared libraries for GDB, the GNU Debugger.
-   Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 1996, 1998 Free Software Foundation, Inc.
    
 This file is part of GDB.
 
@@ -193,8 +193,8 @@ next_link_map_member PARAMS ((struct so_list *));
 static void
 xfer_link_map_member PARAMS ((struct so_list *, struct link_map *));
 
-static void
-solib_map_sections PARAMS ((struct so_list *));
+static int
+solib_map_sections PARAMS ((char *));
 
 /*
 
@@ -204,7 +204,7 @@ LOCAL FUNCTION
 
 SYNOPSIS
 
-       static void solib_map_sections (struct so_list *so)
+       static int solib_map_sections (struct so_list *so)
 
 DESCRIPTION
 
@@ -223,10 +223,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;
@@ -288,6 +289,8 @@ solib_map_sections (so)
 
   /* Free the file names, close the file now.  */
   do_cleanups (old_chain);
+
+  return (1);
 }
 
 /*
@@ -485,7 +488,9 @@ xfer_link_map_member (so_list_ptr, lm)
        }
 #endif
 
-      solib_map_sections (so_list_ptr);
+      catch_errors (solib_map_sections, (char *) so_list_ptr,
+                   "Error while mapping shared library sections:\n",
+                   RETURN_MASK_ALL);
     }
 }
 
@@ -566,9 +571,27 @@ symbol_add_stub (arg)
      char *arg;
 {
   register struct so_list *so = (struct so_list *) arg;        /* catch_errs bogon */
+  CORE_ADDR text_addr = 0;
+
+  if (so -> textsection)
+    text_addr = so -> textsection -> addr;
+  else if (so -> abfd != NULL)
+    {
+      asection *lowest_sect;
+
+      /* If we didn't find a mapped non zero sized .text section, set up
+        text_addr so that the relocation in symbol_file_add does no harm.  */
+
+      lowest_sect = bfd_get_section_by_name (so -> abfd, ".text");
+      if (lowest_sect == NULL)
+       bfd_map_over_sections (so -> abfd, find_lowest_section,
+                              (PTR) &lowest_sect);
+      if (lowest_sect)
+       text_addr = bfd_section_vma (so -> abfd, lowest_sect) + LM_OFFSET (so);
+    }
   
   so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,
-                                  so -> textsection -> addr,
+                                  text_addr,
                                   0, 0, 0);
   return (1);
 }
@@ -770,7 +793,7 @@ GLOBAL FUNCTION
 
 SYNOPSIS
 
-       int solib_address (CORE_ADDR address)
+       char *solib_address (CORE_ADDR address)
 
 DESCRIPTION
 
@@ -786,7 +809,7 @@ DESCRIPTION
        mapped in.
  */
 
-int
+char *
 solib_address (address)
      CORE_ADDR address;
 {
@@ -798,9 +821,7 @@ solib_address (address)
        {
          if ((address >= (CORE_ADDR) so -> textsection -> addr) &&
              (address < (CORE_ADDR) so -> textsection -> endaddr))
-           {
-             return (1);
-           }
+           return (so->so_name);
        }
     }
   return (0);
@@ -907,7 +928,7 @@ solib_create_inferior_hook()
       and will put out an annoying warning.
       Delaying the resetting of stop_soon_quietly until after symbol loading
       suppresses the warning.  */
-  if (auto_solib_add_at_startup)
+  if (auto_solib_add)
     solib_add ((char *) 0, 0, (struct target_ops *) 0);
   stop_soon_quietly = 0;
 }
@@ -946,10 +967,11 @@ _initialize_solib()
 
   add_show_from_set
     (add_set_cmd ("auto-solib-add", class_support, var_zinteger,
-                 (char *) &auto_solib_add_at_startup,
-                 "Set autoloading of shared library symbols at startup.\n\
+                 (char *) &auto_solib_add,
+                 "Set autoloading of shared library symbols.\n\
 If nonzero, symbols from all shared object libraries will be loaded\n\
-automatically when the inferior begins execution.  Otherwise, symbols\n\
+automatically when the inferior begins execution or when the dynamic linker\n\
+informs gdb that a new library has been loaded.  Otherwise, symbols\n\
 must be loaded manually, using `sharedlibrary'.",
                  &setlist),
      &showlist);
This page took 0.025998 seconds and 4 git commands to generate.