From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14841 invoked by alias); 6 Jul 2009 03:03:59 -0000 Received: (qmail 14827 invoked by uid 22791); 6 Jul 2009 03:03:58 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from wf-out-1314.google.com (HELO wf-out-1314.google.com) (209.85.200.168) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Jul 2009 03:03:49 +0000 Received: by wf-out-1314.google.com with SMTP id 23so1450457wfg.24 for ; Sun, 05 Jul 2009 20:03:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.49.20 with SMTP id w20mr1224692wfw.269.1246849427572; Sun, 05 Jul 2009 20:03:47 -0700 (PDT) In-Reply-To: <200907052135.n65LZjeg002063@d12av02.megacenter.de.ibm.com> References: <200907052135.n65LZjeg002063@d12av02.megacenter.de.ibm.com> Date: Mon, 06 Jul 2009 03:03:00 -0000 Message-ID: Subject: Re: [RFA] Check solib bfd arch From: Hui Zhu To: Ulrich Weigand Cc: gdb-patches ml , Michael Snyder Content-Type: multipart/mixed; boundary=000e0cd2a0a838082c046e00c107 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-07/txt/msg00124.txt.bz2 --000e0cd2a0a838082c046e00c107 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-length: 1416 On Mon, Jul 6, 2009 at 05:35, Ulrich Weigand wrote: > Hui Zhu wrote: > >> + =A0/* Check bfd arch. =A0*/ >> + =A0if (bfd_get_arch (abfd) !=3D 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 * 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 =3D gdbarch_bfd_arch_info (target_gdbarch); + if (b->compatible (b, bfd_get_arch_info (abfd)) !=3D b) + { + bfd_close (abfd); + make_cleanup (xfree, found_pathname); + error (_("`%s': ARCH not same with inferior."), found_pathname); + } + return abfd; } --000e0cd2a0a838082c046e00c107 Content-Type: text/plain; charset=US-ASCII; name="solib-check-bfd_arch_info.txt" Content-Disposition: attachment; filename="solib-check-bfd_arch_info.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fwsm14ys0 Content-length: 1005 LS0tCiBzb2xpYi5jIHwgICAxMCArKysrKysrKysrCiAxIGZpbGUgY2hhbmdl ZCwgMTAgaW5zZXJ0aW9ucygrKQoKLS0tIGEvc29saWIuYworKysgYi9zb2xp Yi5jCkBAIC0yODksNiArMjg5LDcgQEAgc29saWJfYmZkX29wZW4gKGNoYXIg KnBhdGhuYW1lKQogICBjaGFyICpmb3VuZF9wYXRobmFtZTsKICAgaW50IGZv dW5kX2ZpbGU7CiAgIGJmZCAqYWJmZDsKKyAgY29uc3Qgc3RydWN0IGJmZF9h cmNoX2luZm8gKmI7CiAKICAgLyogVXNlIHRhcmdldC1zcGVjaWZpYyBvdmVy cmlkZSBpZiBwcmVzZW50LiAgKi8KICAgaWYgKG9wcy0+YmZkX29wZW4pCkBA IC0zMTEsNiArMzEyLDE1IEBAIHNvbGliX2JmZF9vcGVuIChjaGFyICpwYXRo bmFtZSkKIAkgICAgIGZvdW5kX3BhdGhuYW1lLCBiZmRfZXJybXNnIChiZmRf Z2V0X2Vycm9yICgpKSk7CiAgICAgfQogCisgIC8qIENoZWNrIGJmZCBhcmNo LiAgKi8KKyAgYiA9IGdkYmFyY2hfYmZkX2FyY2hfaW5mbyAodGFyZ2V0X2dk YmFyY2gpOworICBpZiAoYi0+Y29tcGF0aWJsZSAoYiwgYmZkX2dldF9hcmNo X2luZm8gKGFiZmQpKSAhPSBiKQorICAgIHsKKyAgICAgIGJmZF9jbG9zZSAo YWJmZCk7CisgICAgICBtYWtlX2NsZWFudXAgKHhmcmVlLCBmb3VuZF9wYXRo bmFtZSk7CisgICAgICBlcnJvciAoXygiYCVzJzogQVJDSCBub3Qgc2FtZSB3 aXRoIGluZmVyaW9yLiIpLCBmb3VuZF9wYXRobmFtZSk7CisgICAgfQorCiAg IHJldHVybiBhYmZkOwogfQogCg== --000e0cd2a0a838082c046e00c107--