From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eoZGO5i2oWKb2gAAWB0awg (envelope-from ) for ; Thu, 09 Jun 2022 05:00:08 -0400 Received: by simark.ca (Postfix, from userid 112) id DD2751E223; Thu, 9 Jun 2022 05:00:08 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=WeGdEr++; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4C7631E143 for ; Thu, 9 Jun 2022 05:00:08 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 774E0383DBA3 for ; Thu, 9 Jun 2022 09:00:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 774E0383DBA3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1654765207; bh=2OHa4WBLiG5ZadsYsq1lPJ5VHgBep7CzUNRFzL1zpP0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=WeGdEr++qYnkOzABKzbnJebnwuMgS77u9NIAXEEhPrTiICyIInWgMPOFjsvqVMg9/ cJzg2MHfGYPqWJIer+roS5nu/bbXqukN68HXNuXykhsX3JqPRTfUMuipdpgYXABcKY phAFjkRJ4R/tWevm4X9HJ5m2mCfwuZHE9OYKN02E= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 9D597385C30F; Thu, 9 Jun 2022 08:58:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9D597385C30F Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CE69C1F9B0; Thu, 9 Jun 2022 08:58:45 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C2A9F13456; Thu, 9 Jun 2022 08:58:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kAhrLkW2oWKJXAAAMHmgww (envelope-from ); Thu, 09 Jun 2022 08:58:45 +0000 Date: Thu, 9 Jun 2022 10:58:44 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb] Fix fbsd core matching Message-ID: <20220609085842.GA32249@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Cc: binutils@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, With an --enable-targets=all build and target board unix/-m32 I run into a FAIL in test-case gdb.base/corefile.exp: ... (gdb) file outputs/gdb.base/corefile/corefile^M Reading symbols from outputs/gdb.base/corefile/corefile...^M (gdb) core-file outputs/gdb.base/corefile/corefile.core^M warning: core file may not match specified executable file.^M [New LWP 12011]^M Core was generated by `outputs/gdb.base/corefile/co'.^M Program terminated with signal SIGABRT, Aborted.^M (gdb) FAIL: gdb.base/corefile.exp: core-file warning-free ... The warning is there because of this mismatch between core and exec: ... (gdb) p core_bfd->xvec $3 = (const struct bfd_target *) 0x20112a0 (gdb) p exec_bfd->xvec $4 = (const struct bfd_target *) 0x2010b00 ... In the exec case, the detected architecture is i386_elf32_vec because this bit of code in elfcode.h:elf_object_p(): ... if (ebd->elf_machine_code != EM_NONE && i_ehdrp->e_ident[EI_OSABI] != ebd->elf_osabi && ebd->elf_osabi != ELFOSABI_NONE) goto got_wrong_format_error; ... prevents i386_elf32_fbsd from matching. Fix the core matching by copying that code to elfcore.h:elf_core_file_p(). Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29227 Any comments? Thanks, - Tom [gdb] Fix fbsd core matching --- bfd/elfcore.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bfd/elfcore.h b/bfd/elfcore.h index 809f6711aed..4ce81e2e383 100644 --- a/bfd/elfcore.h +++ b/bfd/elfcore.h @@ -272,6 +272,11 @@ elf_core_file_p (bfd *abfd) && ebd->elf_machine_code != EM_NONE) goto fail; + if (ebd->elf_machine_code != EM_NONE + && i_ehdrp->e_ident[EI_OSABI] != ebd->elf_osabi + && ebd->elf_osabi != ELFOSABI_NONE) + goto fail; + /* Let the backend double check the format and override global information. We do this before processing the program headers to allow the correct machine (as opposed to just the default