[RFA] Check solib bfd arch
Hui Zhu
teawater@gmail.com
Fri Jul 3 09:52:00 GMT 2009
Hi,
In cross-compile remote debug environment, the gdb will load the solib
of local host if user doesn't set sysroot or something.
Load the wrong lib will make gdb get error.
So I make a patch check the solib bfd arch after load it. I am not
check the other thing in arch_info because the mach of solib and
inferior is not same (powerpc) sometime.
This patch is tested in a i386 ubuntu and powerpc linux.
Thanks,
Hui
2009-07-03 Hui Zhu <teawater@gmail.com>
* solib.c (solib_bfd_open): Check solib bfd arch.
---
solib.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/solib.c
+++ b/solib.c
@@ -311,6 +311,14 @@ solib_bfd_open (char *pathname)
found_pathname, bfd_errmsg (bfd_get_error ()));
}
+ /* Check bfd arch. */
+ if (bfd_get_arch (abfd) != gdbarch_bfd_arch_info (target_gdbarch)->arch)
+ {
+ bfd_close (abfd);
+ make_cleanup (xfree, found_pathname);
+ error (_("`%s': ARCH not same with inferior."), found_pathname);
+ }
+
return abfd;
}
-------------- next part --------------
---
solib.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/solib.c
+++ b/solib.c
@@ -311,6 +311,14 @@ solib_bfd_open (char *pathname)
found_pathname, bfd_errmsg (bfd_get_error ()));
}
+ /* Check bfd arch. */
+ if (bfd_get_arch (abfd) != gdbarch_bfd_arch_info (target_gdbarch)->arch)
+ {
+ bfd_close (abfd);
+ make_cleanup (xfree, found_pathname);
+ error (_("`%s': ARCH not same with inferior."), found_pathname);
+ }
+
return abfd;
}
More information about the Gdb-patches
mailing list