From: Hui Zhu <teawater@gmail.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: gdb-patches ml <gdb-patches@sourceware.org>,
Michael Snyder <msnyder@vmware.com>
Subject: Re: [RFA] Check solib bfd arch
Date: Wed, 08 Jul 2009 02:46:00 -0000 [thread overview]
Message-ID: <daef60380907071946j414bf12fub984540640102edc@mail.gmail.com> (raw)
In-Reply-To: <200907071645.n67GjR0X001418@d12av02.megacenter.de.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2106 bytes --]
On Wed, Jul 8, 2009 at 00:45, Ulrich Weigand<uweigand@de.ibm.com> wrote:
> Hui Zhu wrote:
>
>> + /* 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);
>> + }
>
> I'm not sure this should be an error; we allow debugging a main
> executable whose architecture does not match the target architecture
> (if the user knows what they're doing), so IMO we should allow this
> for shared libraries too. A *warning* would be more appropriate.
>
> Also, I think it would be good if the message mentioned the architecture
> in question, along the lines of:
>
> warning (_("`%s': Shared library architecture %s is not compatible "
> "with target architecture %s."), found_pathname,
> bfd_get_arch_info (abfd)->printable_name, b->printable_name);
>
Agree with you. I make a new patch for it.
Please help me review it. Thanks.
Hui
2009-07-08 Hui Zhu <teawater@gmail.com>
* solib.c (solib_bfd_open): Output a warning if solib's
architecture is not compatible with inferior's architecture.
---
solib.c | 8 ++++++++
1 file changed, 8 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,13 @@ 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)
+ warning (_("`%s': Shared library architecture %s is not compatible "
+ "with target architecture %s."), found_pathname,
+ bfd_get_arch_info (abfd)->printable_name, b->printable_name);
+
return abfd;
}
[-- Attachment #2: solib-check-bfd_arch_info.txt --]
[-- Type: text/plain, Size: 795 bytes --]
---
solib.c | 8 ++++++++
1 file changed, 8 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,13 @@ 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)
+ warning (_("`%s': Shared library architecture %s is not compatible "
+ "with target architecture %s."), found_pathname,
+ bfd_get_arch_info (abfd)->printable_name, b->printable_name);
+
return abfd;
}
next prev parent reply other threads:[~2009-07-08 2:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-03 9:52 Hui Zhu
2009-07-05 21:36 ` Ulrich Weigand
2009-07-06 3:03 ` Hui Zhu
2009-07-07 16:45 ` Ulrich Weigand
2009-07-08 2:46 ` Hui Zhu [this message]
2009-07-09 13:43 ` Ulrich Weigand
2009-07-09 16:50 ` Hui Zhu
2009-09-17 22:56 ` Joel Brobecker
2009-09-18 5:05 ` Hui Zhu
2009-09-18 12:50 ` Ulrich Weigand
2009-09-18 13:06 ` Ulrich Weigand
2009-09-18 13:10 ` Daniel Jacobowitz
2009-09-18 14:24 ` Joel Brobecker
2009-09-18 14:08 ` Mark Kettenis
2009-09-18 14:11 ` Mark Kettenis
2009-09-18 14:39 ` Daniel Jacobowitz
2009-09-18 14:53 ` Pedro Alves
2009-09-18 16:14 ` Ulrich Weigand
2009-09-18 16:25 ` Daniel Jacobowitz
2009-09-18 16:41 ` Pedro Alves
2009-09-18 16:44 ` Daniel Jacobowitz
2009-09-18 16:45 ` Pedro Alves
2009-09-18 17:17 ` Joel Brobecker
2009-09-18 20:43 ` Joel Brobecker
2009-09-22 23:04 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=daef60380907071946j414bf12fub984540640102edc@mail.gmail.com \
--to=teawater@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=msnyder@vmware.com \
--cc=uweigand@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox