From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 62D1D3857343; Thu, 9 Jun 2022 15:59:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 62D1D3857343 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 69EA177A03; Thu, 9 Jun 2022 15:59:39 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LJpgv2Hvpz4Wcq; Thu, 9 Jun 2022 15:59:39 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654790379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QYC0A0c98UlDHXkdgZhwJ0BX+rHZxCV4dIVZusqpsxw=; b=b0wadwywqTP4mfsK78JBQrVdgK+4aaWRJV9q8b8u5na/MlFESmBGLkcfewHKf6kgqvQubv GVzunJLskqzUebACCxlqGWdFwbqlNW33Mas36Y3RcsVQBYAA6cgHLWmRogs0cmVxi2nVU1 c6LLBxH82GEwFYHPIaQDl+aBucCpbm/IViYsz7ojS8O0ouRODv40Mnn7FlXa9UeuwG2PVX SUlP3y6GytkrpTd8XpxhNaGUhb1nKHPeYO34vQ415KXoK74KQwyM/+GsixmoimC1m+8D3C K+km9NOVAL4MOapUxBR/raYR4HL9axqIuCXO14RONBcx7o40Az9NFztoohJqGA== Received: from [IPV6:2601:648:8680:ed60:28bd:dfeb:9ce6:e4ee] (unknown [IPv6:2601:648:8680:ed60:28bd:dfeb:9ce6:e4ee]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 8B8E721D84; Thu, 9 Jun 2022 15:59:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <790e4948-9a70-a7c7-f562-a2bf16a54506@FreeBSD.org> Date: Thu, 9 Jun 2022 08:59:37 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH][gdb] Fix fbsd core matching Content-Language: en-US To: Tom de Vries , gdb-patches@sourceware.org Cc: binutils@sourceware.org, amodra@gmail.com References: <20220609085842.GA32249@delia.home> From: John Baldwin In-Reply-To: <20220609085842.GA32249@delia.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654790379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QYC0A0c98UlDHXkdgZhwJ0BX+rHZxCV4dIVZusqpsxw=; b=UIL3TcVZ5pbxOkHWcswb/mSup4+r7GtUAVOMFEU2/bFyZ1EkCkVnGQGv4fmyFOglySLAnl 66NcAZn8PB6Nhuh00Z7Pyzlm1kI1S5V75YYp4PP8A27mjAP6mmz0Sqmm9l7dGzPbN4IyKq lzi4EaaYNnbmPT/S/Qj+rlIxll2TmFLnSs7asnofJMqgTk7wL/CyLPVb+4l0/9nMA52VW0 hottA1v/tRJD0+hhmN62hHQMr6iQxCDVrzgvwxLSz0WGyUhDhgyh92G4XhVd+aqfqw4QeP tbs5OlzuJADnNCfpCDu1huxef5aKVBgr/raOV+4wFntG/2cs23T6/CpbJZmOjQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654790379; a=rsa-sha256; cv=none; b=fVgEKtgKkuuKZO5XbeA8JkM1OgQA433U5YGmbEknOQVkXArruTgTGgA5fbSZbwlyTniZKi qzPqj5nZxSgDNb2W8iC8jiX3t6YxqCUO6g1apGHF52QtQJysz4jyyiCab8NrthSQEwvkBX aF671cdZpK0SIqXr4puV0SBUhXvN1A0LZ3sShDY1e3/OX0DM2kgdVpPhCkAcQYEgz3Sx1L o4Opz0ir/0R2Ef624PKZtvhJsTAklWo6hx3JtEW+rfnPu1Jiza9rYr+Osl6LSwaUFc/OJF JNbt/uUxx2gXlDYbSKDuI8I3tk3KFrA9A+PDFuJG6/JDQLja2UD7LFoRY2cPPQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jun 2022 15:59:44 -0000 On 6/9/22 1:58 AM, Tom de Vries via Gdb-patches wrote: > 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? Looking at elfcore.h, it seems to have not gotten changes made to elfcode.h over time and is a bit rotted. I suspect that all of changes made in commit 0aabe54e6222 that added these lines in elfcode.h (along with several other changes) need to be applied to this function in elfcore.h, not just adding these lines. I've cc'd Alan who made that commit above to elfcore.h. There also seem to be some other inconsistencies between the functions in elfcore.h and and elfcode.h and perhaps the common functionality in these functions could be refactored into a separate function to avoid the code duplication? Note that the issue isn't really FreeBSD specific, I just suspect that the FreeBSD i386 vec happens to be sorted first in the list for some reason. > 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 -- John Baldwin