aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib.c
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2011-08-30 02:48:05 +0000
committerYao Qi <yao@codesourcery.com>2011-08-30 02:48:05 +0000
commitcb457ae2842770922180ce15b4885ff7b224bf95 (patch)
tree5a9c61c90c03d02339fe5a3926632370f9a462be /gdb/solib.c
parent83d1a36ae4e69a3bc19f9aae6c009e7d91d31ad6 (diff)
downloadgdb-cb457ae2842770922180ce15b4885ff7b224bf95.zip
gdb-cb457ae2842770922180ce15b4885ff7b224bf95.tar.gz
gdb-cb457ae2842770922180ce15b4885ff7b224bf95.tar.bz2
gdb/
* solib-dsbt.c (bfd_lookup_symbol): Removed. (cmp_name): New. (enable_break2): Update caller. * solib-frv.c (bfd_lookup_symbol): Removed. (cmp_name): New. (enable_break2): Update caller. * solib-pa64.c (bfd_lookup_symbol): Removed. (cmp_name): New. * solib-svr4.c (bfd_lookup_symbol): Removed. (cmp_name_and_sec_flags): New. (enable_break): Update caller. * solib.c (gdb_bfd_lookup_symbol_from_symtab): New. (gdb_bfd_lookup_symbol_from_dyn_symtab): New. (gdb_bfd_lookup_symbol): New. * solib.h: Functions declarations.
Diffstat (limited to 'gdb/solib.c')
-rw-r--r--gdb/solib.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/gdb/solib.c b/gdb/solib.c
index f843723..6c0a899 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1336,6 +1336,102 @@ solib_global_lookup (const struct objfile *objfile,
return 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) (asymbol *, void *),
+ 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))
+ {
+ /* BFD symbols are section relative. */
+ symaddr = sym->value + 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) (asymbol *, void *),
+ 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;
+}
+
+/* Lookup the value for a specific symbol from symbol table and 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 (bfd *abfd,
+ int (*match_sym) (asymbol *, void *),
+ void *data)
+{
+ CORE_ADDR symaddr = gdb_bfd_lookup_symbol_from_symtab (abfd, match_sym, data);
+
+ /* On FreeBSD, the dynamic linker is stripped by default. So we'll
+ have to check the dynamic string table too. */
+ if (symaddr == 0)
+ symaddr = bfd_lookup_symbol_from_dyn_symtab (abfd, match_sym, data);
+
+ return symaddr;
+}
extern initialize_file_ftype _initialize_solib; /* -Wmissing-prototypes */