gdb/
[deliverable/binutils-gdb.git] / gdb / solib-svr4.c
index f643a2475bddcb86c7380736a853cd02f5f61566..d58ca1a26e08e8f74092f1f59b7ad8175d4b7450 100644 (file)
@@ -370,86 +370,6 @@ get_svr4_info (void)
 
 static int match_main (const char *);
 
-/* Lookup the value for a specific symbol.
-
-   An expensive way to lookup the value of a single symbol for
-   bfd's that are only temporary anyway.  This is used by the
-   shared library support to find the address of the debugger
-   notification routine in the shared library.
-
-   The returned symbol may be in a code or data section; functions
-   will normally be in a code section, but may be in a data section
-   if this architecture uses function descriptors.
-
-   Note that 0 is specifically allowed as an error return (no
-   such symbol).  */
-
-static CORE_ADDR
-bfd_lookup_symbol (bfd *abfd, const char *symname)
-{
-  long storage_needed;
-  asymbol *sym;
-  asymbol **symbol_table;
-  unsigned int number_of_symbols;
-  unsigned int i;
-  struct cleanup *back_to;
-  CORE_ADDR symaddr = 0;
-
-  storage_needed = bfd_get_symtab_upper_bound (abfd);
-
-  if (storage_needed > 0)
-    {
-      symbol_table = (asymbol **) xmalloc (storage_needed);
-      back_to = make_cleanup (xfree, symbol_table);
-      number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
-
-      for (i = 0; i < number_of_symbols; i++)
-       {
-         sym = *symbol_table++;
-         if (strcmp (sym->name, symname) == 0
-              && (sym->section->flags & (SEC_CODE | SEC_DATA)) != 0)
-           {
-             /* BFD symbols are section relative.  */
-             symaddr = sym->value + sym->section->vma;
-             break;
-           }
-       }
-      do_cleanups (back_to);
-    }
-
-  if (symaddr)
-    return symaddr;
-
-  /* On FreeBSD, the dynamic linker is stripped by default.  So we'll
-     have to check the dynamic string table too.  */
-
-  storage_needed = bfd_get_dynamic_symtab_upper_bound (abfd);
-
-  if (storage_needed > 0)
-    {
-      symbol_table = (asymbol **) xmalloc (storage_needed);
-      back_to = make_cleanup (xfree, symbol_table);
-      number_of_symbols = bfd_canonicalize_dynamic_symtab (abfd, symbol_table);
-
-      for (i = 0; i < number_of_symbols; i++)
-       {
-         sym = *symbol_table++;
-
-         if (strcmp (sym->name, symname) == 0
-              && (sym->section->flags & (SEC_CODE | SEC_DATA)) != 0)
-           {
-             /* BFD symbols are section relative.  */
-             symaddr = sym->value + sym->section->vma;
-             break;
-           }
-       }
-      do_cleanups (back_to);
-    }
-
-  return symaddr;
-}
-
-
 /* Read program header TYPE from inferior memory.  The header is found
    by scanning the OS auxillary vector.
 
@@ -1253,6 +1173,14 @@ exec_entry_point (struct bfd *abfd, struct target_ops *targ)
                                             targ);
 }
 
+/* Helper function for gdb_bfd_lookup_symbol.  */
+
+static int
+cmp_name_and_sec_flags (asymbol *sym, void *data)
+{
+  return (strcmp (sym->name, (const char *) data) == 0
+         && (sym->section->flags & (SEC_CODE | SEC_DATA)) != 0);
+}
 /* Arrange for dynamic linker to hit breakpoint.
 
    Both the SunOS and the SVR4 dynamic linkers have, as part of their
@@ -1501,7 +1429,8 @@ enable_break (struct svr4_info *info, int from_tty)
       /* Now try to set a breakpoint in the dynamic linker.  */
       for (bkpt_namep = solib_break_names; *bkpt_namep != NULL; bkpt_namep++)
        {
-         sym_addr = bfd_lookup_symbol (tmp_bfd, *bkpt_namep);
+         sym_addr = gdb_bfd_lookup_symbol (tmp_bfd, cmp_name_and_sec_flags,
+                                           (void *) *bkpt_namep);
          if (sym_addr != 0)
            break;
        }
This page took 0.024764 seconds and 4 git commands to generate.