This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Simplify overriding the target_so_ops.bfd_open hook
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 17 Jul 2009 19:09:18 +0200 (CEST)
- Subject: [commit] Simplify overriding the target_so_ops.bfd_open hook
Hello,
the "bfd_open" member of struct target_so_ops that I recently introduced
has a somewhat atypical semantics: solib_bfd_open calls this member if
non-NULL; otherwise it performs its own lookup.
This means that every target that overrides the bfd_open member has no
easy way of "falling back" to the default implementation in some cases,
without duplicating the whole rest of solib_bfd_open. I've been running
into this issue with the Cell/B.E. patches.
This patch simplifies this by just using solib_bfd_open as the default
implementation of the bfd_open hook, and *not* calling the hook from
solib_bfd_open itself. Other implementations of the hook can then call
to solib_bfd_open for the default case.
Tested on powerpc64-linux with no regression; compile-tested with
--enable-targets=all.
Committed to mainline.
Bye,
Ulrich
ChangeLog:
* solib.c (solib_bfd_open): Do not call ops->bfd_open.
(solib_map_sections): Call ops->bfd_open instead of solib_bfd_open.
* solib-frv.c (_initialize_frv_solib): Initialize bfd_open member.
* solib-irix.c (_initialize_irix_solib): Likewise.
* solib-null.c (_initialize_null_solib): Likewise.
* solib-osf.c (_initialize_osf_solib): Likewise.
* solib-pa64.c (_initialize_pa64_solib): Likewise.
* solib-som.c (_initialize_som_solib): Likewise.
* solib-sunos.c (_initialize_sunos_solib): Likewise.
* solib-svr4.c (_initialize_svr4_solib): Likewise.
* solib-target.c (_initialize_solib_target): Likewise.
Index: gdb/solib-frv.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-frv.c,v
retrieving revision 1.28
diff -u -p -r1.28 solib-frv.c
--- gdb/solib-frv.c 2 Jul 2009 17:25:58 -0000 1.28
+++ gdb/solib-frv.c 15 Jul 2009 18:15:49 -0000
@@ -1300,6 +1300,7 @@ _initialize_frv_solib (void)
frv_so_ops.current_sos = frv_current_sos;
frv_so_ops.open_symbol_file_object = open_symbol_file_object;
frv_so_ops.in_dynsym_resolve_code = frv_in_dynsym_resolve_code;
+ frv_so_ops.bfd_open = solib_bfd_open;
/* Debug this file's internals. */
add_setshow_zinteger_cmd ("solib-frv", class_maintenance,
Index: gdb/solib-irix.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-irix.c,v
retrieving revision 1.27
diff -u -p -r1.27 solib-irix.c
--- gdb/solib-irix.c 2 Jul 2009 17:25:58 -0000 1.27
+++ gdb/solib-irix.c 15 Jul 2009 18:15:49 -0000
@@ -740,4 +740,5 @@ _initialize_irix_solib (void)
irix_so_ops.current_sos = irix_current_sos;
irix_so_ops.open_symbol_file_object = irix_open_symbol_file_object;
irix_so_ops.in_dynsym_resolve_code = irix_in_dynsym_resolve_code;
+ irix_so_ops.bfd_open = solib_bfd_open;
}
Index: gdb/solib-null.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-null.c,v
retrieving revision 1.7
diff -u -p -r1.7 solib-null.c
--- gdb/solib-null.c 22 May 2009 23:49:13 -0000 1.7
+++ gdb/solib-null.c 15 Jul 2009 18:15:49 -0000
@@ -81,6 +81,7 @@ _initialize_null_solib (void)
null_so_ops.current_sos = null_current_sos;
null_so_ops.open_symbol_file_object = null_open_symbol_file_object;
null_so_ops.in_dynsym_resolve_code = null_in_dynsym_resolve_code;
+ null_so_ops.bfd_open = solib_bfd_open;
/* Set current_target_so_ops to null_so_ops if not already set. */
if (current_target_so_ops == 0)
Index: gdb/solib-osf.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-osf.c,v
retrieving revision 1.25
diff -u -p -r1.25 solib-osf.c
--- gdb/solib-osf.c 22 May 2009 23:49:13 -0000 1.25
+++ gdb/solib-osf.c 15 Jul 2009 18:15:49 -0000
@@ -631,6 +631,7 @@ _initialize_osf_solib (void)
osf_so_ops.current_sos = osf_current_sos;
osf_so_ops.open_symbol_file_object = osf_open_symbol_file_object;
osf_so_ops.in_dynsym_resolve_code = osf_in_dynsym_resolve_code;
+ osf_so_ops.bfd_open = solib_bfd_open;
/* FIXME: Don't do this here. *_gdbarch_init() should set so_ops. */
current_target_so_ops = &osf_so_ops;
Index: gdb/solib-pa64.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-pa64.c,v
retrieving revision 1.19
diff -u -p -r1.19 solib-pa64.c
--- gdb/solib-pa64.c 2 Jul 2009 17:12:27 -0000 1.19
+++ gdb/solib-pa64.c 15 Jul 2009 18:15:49 -0000
@@ -658,6 +658,7 @@ _initialize_pa64_solib (void)
pa64_so_ops.current_sos = pa64_current_sos;
pa64_so_ops.open_symbol_file_object = pa64_open_symbol_file_object;
pa64_so_ops.in_dynsym_resolve_code = pa64_in_dynsym_resolve_code;
+ pa64_so_ops.bfd_open = solib_bfd_open;
memset (&dld_cache, 0, sizeof (dld_cache));
}
Index: gdb/solib-som.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-som.c,v
retrieving revision 1.24
diff -u -p -r1.24 solib-som.c
--- gdb/solib-som.c 2 Jul 2009 17:25:58 -0000 1.24
+++ gdb/solib-som.c 15 Jul 2009 18:15:50 -0000
@@ -812,6 +812,7 @@ _initialize_som_solib (void)
som_so_ops.current_sos = som_current_sos;
som_so_ops.open_symbol_file_object = som_open_symbol_file_object;
som_so_ops.in_dynsym_resolve_code = som_in_dynsym_resolve_code;
+ som_so_ops.bfd_open = solib_bfd_open;
}
void
Index: gdb/solib-sunos.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-sunos.c,v
retrieving revision 1.35
diff -u -p -r1.35 solib-sunos.c
--- gdb/solib-sunos.c 2 Jul 2009 17:25:58 -0000 1.35
+++ gdb/solib-sunos.c 15 Jul 2009 18:15:50 -0000
@@ -840,6 +840,7 @@ _initialize_sunos_solib (void)
sunos_so_ops.current_sos = sunos_current_sos;
sunos_so_ops.open_symbol_file_object = open_symbol_file_object;
sunos_so_ops.in_dynsym_resolve_code = sunos_in_dynsym_resolve_code;
+ sunos_so_ops.bfd_open = solib_bfd_open;
/* FIXME: Don't do this here. *_gdbarch_init() should set so_ops. */
current_target_so_ops = &sunos_so_ops;
Index: gdb/solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.104
diff -u -p -r1.104 solib-svr4.c
--- gdb/solib-svr4.c 2 Jul 2009 17:25:58 -0000 1.104
+++ gdb/solib-svr4.c 15 Jul 2009 18:15:50 -0000
@@ -1934,6 +1934,7 @@ _initialize_svr4_solib (void)
svr4_so_ops.current_sos = svr4_current_sos;
svr4_so_ops.open_symbol_file_object = open_symbol_file_object;
svr4_so_ops.in_dynsym_resolve_code = svr4_in_dynsym_resolve_code;
+ svr4_so_ops.bfd_open = solib_bfd_open;
svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol;
svr4_so_ops.same = svr4_same;
Index: gdb/solib-target.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-target.c,v
retrieving revision 1.11
diff -u -p -r1.11 solib-target.c
--- gdb/solib-target.c 22 May 2009 23:49:13 -0000 1.11
+++ gdb/solib-target.c 15 Jul 2009 18:15:50 -0000
@@ -492,4 +492,5 @@ _initialize_solib_target (void)
= solib_target_open_symbol_file_object;
solib_target_so_ops.in_dynsym_resolve_code
= solib_target_in_dynsym_resolve_code;
+ solib_target_so_ops.bfd_open = solib_bfd_open;
}
Index: gdb/solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.121
diff -u -p -r1.121 solib.c
--- gdb/solib.c 9 Jul 2009 13:39:17 -0000 1.121
+++ gdb/solib.c 15 Jul 2009 18:15:51 -0000
@@ -285,16 +285,11 @@ solib_bfd_fopen (char *pathname, int fd)
bfd *
solib_bfd_open (char *pathname)
{
- struct target_so_ops *ops = solib_ops (target_gdbarch);
char *found_pathname;
int found_file;
bfd *abfd;
const struct bfd_arch_info *b;
- /* Use target-specific override if present. */
- if (ops->bfd_open)
- return ops->bfd_open (pathname);
-
/* Search for shared library file. */
found_pathname = solib_find (pathname, &found_file);
if (found_pathname == NULL)
@@ -354,6 +349,7 @@ 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 target_section *p;
struct cleanup *old_chain;
@@ -361,7 +357,7 @@ solib_map_sections (void *arg)
filename = tilde_expand (so->so_name);
old_chain = make_cleanup (xfree, filename);
- abfd = solib_bfd_open (filename);
+ abfd = ops->bfd_open (filename);
do_cleanups (old_chain);
/* Leave bfd open, core_xfer_memory and "info files" need it. */
@@ -381,8 +377,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. */
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com