This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] [05/18] Cell multi-arch: Non-file-backed shared library BFD infrastructure
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Sun, 7 Sep 2008 23:12:55 +0200 (CEST)
- Subject: [rfc] [05/18] Cell multi-arch: Non-file-backed shared library BFD infrastructure
Hello,
as a minor infrastructure extension, this patch allows a solib implementation
to provide BFDs to access a shared library that is not found in the file
system. This is used by the Cell debugger to retrieve embedded SPU executable
images from inferior memory.
Bye,
Ulrich
ChangeLog:
* solib.h (struct target_so_ops): New member open_bfd.
* solib.c (solib_map_sections): Use open_bfd callback if present.
(symbol_add_stub): Likewise.
Index: src/gdb/solib.c
===================================================================
--- src.orig/gdb/solib.c
+++ src/gdb/solib.c
@@ -311,15 +311,22 @@ static int
solib_map_sections (void *arg)
{
struct so_list *so = (struct so_list *) arg; /* catch_errors bogon */
+ struct target_so_ops *ops = solib_ops (target_gdbarch);
char *filename;
struct section_table *p;
struct cleanup *old_chain;
- bfd *abfd;
+ bfd *abfd = NULL;
+
+ if (ops->open_bfd)
+ abfd = ops->open_bfd (so->so_name);
- filename = tilde_expand (so->so_name);
- old_chain = make_cleanup (xfree, filename);
- abfd = solib_bfd_open (filename);
- do_cleanups (old_chain);
+ if (!abfd)
+ {
+ filename = tilde_expand (so->so_name);
+ old_chain = make_cleanup (xfree, filename);
+ abfd = solib_bfd_open (filename);
+ do_cleanups (old_chain);
+ }
/* Leave bfd open, core_xfer_memory and "info files" need it. */
so->abfd = abfd;
@@ -338,8 +345,6 @@ solib_map_sections (void *arg)
for (p = so->sections; p < so->sections_end; p++)
{
- struct target_so_ops *ops = solib_ops (target_gdbarch);
-
/* Relocate the section binding addresses as recorded in the shared
object's file by the base address to which the object was actually
mapped. */
@@ -420,7 +425,9 @@ static int
symbol_add_stub (void *arg)
{
struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
+ struct target_so_ops *ops = solib_ops (target_gdbarch);
struct section_addr_info *sap;
+ bfd *abfd = NULL;
/* Have we already loaded this shared object? */
ALL_OBJFILES (so->objfile)
@@ -429,11 +436,18 @@ symbol_add_stub (void *arg)
return 1;
}
+ /* Open a second BFD for this file. */
+ if (ops->open_bfd)
+ abfd = ops->open_bfd (so->so_name);
+
+ if (!abfd)
+ abfd = symfile_bfd_open (so->so_name);
+
sap = build_section_addr_info_from_section_table (so->sections,
so->sections_end);
- so->objfile = symbol_file_add (so->so_name, so->from_tty,
- sap, 0, OBJF_SHARED);
+ so->objfile = symbol_file_add_from_bfd (abfd, so->from_tty,
+ sap, 0, OBJF_SHARED);
free_section_addr_info (sap);
return (1);
Index: src/gdb/solist.h
===================================================================
--- src.orig/gdb/solist.h
+++ src/gdb/solist.h
@@ -118,6 +118,10 @@ struct target_so_ops
and another from the list returned by current_sos, return 1
if they represent the same library. */
int (*same) (struct so_list *gdb, struct so_list *inferior);
+
+ /* Extra hook for opening a BFD for a solib. Can be used to
+ retrieve solibs from inferior memory instead of from files. */
+ bfd *(*open_bfd) (char *pathname);
};
/* Free the memory associated with a (so_list *). */
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com