This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Check solib bfd arch


On Mon, Jul 6, 2009 at 05:35, Ulrich Weigand<uweigand@de.ibm.com> wrote:
> Hui Zhu wrote:
>
>> + ?/* Check bfd arch. ?*/
>> + ?if (bfd_get_arch (abfd) != gdbarch_bfd_arch_info (target_gdbarch)->arch)
>
> This test seems to strict; there are cases where code of a different
> architecture *can* actually run on the current architecture (e.g.
> bfd_arch_rs6000 vs. bfd_arch_powerpc).
>
> The correct check would be something alone the lines of
> osabi.c:can_run_code_for.
>

Thanks Ulrich.

I make a new patch that use "compatible".  Please help me review it.

Thanks,
Hui

2009-07-06  Hui Zhu  <teawater@gmail.com>

	* solib.c (solib_bfd_open): Check solib bfd arch.

---
 solib.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/solib.c
+++ b/solib.c
@@ -289,6 +289,7 @@ solib_bfd_open (char *pathname)
   char *found_pathname;
   int found_file;
   bfd *abfd;
+  const struct bfd_arch_info *b;

   /* Use target-specific override if present.  */
   if (ops->bfd_open)
@@ -311,6 +312,15 @@ solib_bfd_open (char *pathname)
 	     found_pathname, bfd_errmsg (bfd_get_error ()));
     }

+  /* Check bfd arch.  */
+  b = gdbarch_bfd_arch_info (target_gdbarch);
+  if (b->compatible (b, bfd_get_arch_info (abfd)) != b)
+    {
+      bfd_close (abfd);
+      make_cleanup (xfree, found_pathname);
+      error (_("`%s': ARCH not same with inferior."), found_pathname);
+    }
+
   return abfd;
 }

Attachment: solib-check-bfd_arch_info.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]