+ return (struct block_symbol) {NULL, NULL};
+}
+
+/* Lookup the value for a specific symbol from dynamic symbol table. Look
+ up symbol from ABFD. MATCH_SYM is a callback function to determine
+ whether to pick up a symbol. DATA is the input of this callback
+ function. Return NULL if symbol is not found. */
+
+CORE_ADDR
+gdb_bfd_lookup_symbol_from_symtab (bfd *abfd,
+ int (*match_sym) (const asymbol *,
+ const void *),
+ const void *data)
+{
+ long storage_needed = bfd_get_symtab_upper_bound (abfd);
+ CORE_ADDR symaddr = 0;
+
+ if (storage_needed > 0)
+ {
+ unsigned int i;
+
+ asymbol **symbol_table = (asymbol **) xmalloc (storage_needed);
+ struct cleanup *back_to = make_cleanup (xfree, symbol_table);
+ unsigned int number_of_symbols =
+ bfd_canonicalize_symtab (abfd, symbol_table);
+
+ for (i = 0; i < number_of_symbols; i++)
+ {
+ asymbol *sym = *symbol_table++;
+
+ if (match_sym (sym, data))
+ {
+ struct gdbarch *gdbarch = target_gdbarch ();
+ symaddr = sym->value;
+
+ /* Some ELF targets fiddle with addresses of symbols they
+ consider special. They use minimal symbols to do that
+ and this is needed for correct breakpoint placement,
+ but we do not have full data here to build a complete
+ minimal symbol, so just set the address and let the
+ targets cope with that. */
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
+ && gdbarch_elf_make_msymbol_special_p (gdbarch))
+ {
+ struct minimal_symbol msym;
+
+ memset (&msym, 0, sizeof (msym));
+ SET_MSYMBOL_VALUE_ADDRESS (&msym, symaddr);
+ gdbarch_elf_make_msymbol_special (gdbarch, sym, &msym);
+ symaddr = MSYMBOL_VALUE_RAW_ADDRESS (&msym);
+ }
+
+ /* BFD symbols are section relative. */
+ symaddr += sym->section->vma;
+ break;
+ }
+ }
+ do_cleanups (back_to);
+ }
+
+ return symaddr;
+}
+
+/* Lookup the value for a specific symbol from symbol table. Look up symbol
+ from ABFD. MATCH_SYM is a callback function to determine whether to pick
+ up a symbol. DATA is the input of this callback function. Return NULL
+ if symbol is not found. */
+
+static CORE_ADDR
+bfd_lookup_symbol_from_dyn_symtab (bfd *abfd,
+ int (*match_sym) (const asymbol *,
+ const void *),
+ const void *data)
+{
+ long storage_needed = bfd_get_dynamic_symtab_upper_bound (abfd);
+ CORE_ADDR symaddr = 0;
+
+ if (storage_needed > 0)
+ {
+ unsigned int i;
+ asymbol **symbol_table = (asymbol **) xmalloc (storage_needed);
+ struct cleanup *back_to = make_cleanup (xfree, symbol_table);
+ unsigned int number_of_symbols =
+ bfd_canonicalize_dynamic_symtab (abfd, symbol_table);
+
+ for (i = 0; i < number_of_symbols; i++)
+ {
+ asymbol *sym = *symbol_table++;
+
+ if (match_sym (sym, data))
+ {
+ /* BFD symbols are section relative. */
+ symaddr = sym->value + sym->section->vma;
+ break;
+ }
+ }
+ do_cleanups (back_to);
+ }
+ return symaddr;