From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26600 invoked by alias); 12 Jan 2016 19:08:26 -0000 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 Received: (qmail 26589 invoked by uid 89); 12 Jan 2016 19:08:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=carry X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 12 Jan 2016 19:08:25 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 21E03C0AA384; Tue, 12 Jan 2016 19:08:24 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0CJ8MRu011881; Tue, 12 Jan 2016 14:08:23 -0500 Message-ID: <56954F26.70501@redhat.com> Date: Tue, 12 Jan 2016 19:08:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "Maciej W. Rozycki" , Luis Machado CC: gdb-patches@sourceware.org, jan.kratochvil@redhat.com Subject: Re: [PATCH] Handle loading improper core files gracefully in the mips backend. References: <1452277948-25292-1-git-send-email-lgustavo@codesourcery.com> <5693CE90.1060709@codesourcery.com> <5694F5BC.3050904@redhat.com> <5694FEB8.10406@codesourcery.com> <56950952.2030504@redhat.com> <56951F29.7070000@codesourcery.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-01/txt/msg00234.txt.bz2 On 01/12/2016 06:30 PM, Maciej W. Rozycki wrote: > On Tue, 12 Jan 2016, Luis Machado wrote: >> Pedro Alves wrote: > >>> I also wonder whether the bfd arch detection couldn't be always >>> compiled in, at least for elf. Why does bfd fail to detect that this >>> is an bfd_arch_i386 file in the first place? > > The mapping between `e_machine' and `bfd_architecture' is only provided > by individual BFD ELF target backends, via the ELF_MACHINE_CODE and > ELF_ARCH macros. Thanks. In principle, it sounds to me that at least the ELF_MACHINE_CODE -> bfd_architecture sniffing bits could be factored out and always be present. But, that might not be practical. >> Sounds like we have a couple issues. The mips backend not handling weird >> abi/isa combinations and GDB not preventing clearly incompatible core files >> from proceeding further into processing in the target's backend? > > I have given it some thought and came to a conclusion that we should at > least try being consistent. Which means I think we should not try to > handle files within the MIPS backend which would not be passed in the > first place in an `--enable-targets=all' configuration. Rather than > checking `e_machine' explicitly I'd be leaning towards using BFD to detect > such a situation though, perhaps by using a condition like > > if (info.abfd != NULL > && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour > && bfd_get_arch (info.abfd) != bfd_arch_mips) > return NULL; > > (maybe with an additional error message) though ultimately I think it > would make sense to define different BFD architecture codes for file > formats which by definition carry no architecture information and for ones > that do but are not supported. Agreed. Seems like that could be the job of bfd_arch_obscure -- it's used as default/unhandled case in some formats that do have architecture information. Though it isn't used throughout all bfd backends. > Then for the formers we could continue > selecting the target using the current algorithm and for the latters we'd > just reject them as incompatible with the given backend -- all somewhere > in generic code so that individual target backends do not have to repeat > it all. > > As to ABI, ISA, etc. settings -- these are internal to the MIPS backend, > so its the backend's job to sanitise them. /me nods. Thanks, Pedro Alves