From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway24.websitewelcome.com (gateway24.websitewelcome.com [192.185.51.61]) by sourceware.org (Postfix) with ESMTPS id 70B103858400 for ; Wed, 17 Nov 2021 14:22:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 70B103858400 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tromey.com Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 0C1DCAD28AC for ; Wed, 17 Nov 2021 08:19:41 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id nLkqmcpcQgm2UnLkqmCG17; Wed, 17 Nov 2021 08:17:40 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=G9eXDJRM+b5uWEW2pb4zaCa+jyTXdm9nJh87ax2GVpQ=; b=xqr5JqxDaZQmAjY1cdJoFf+y6g ZJapIOgJavU7GEmL7kZQCFu+420oRoOEe7EEQNBpGV09sS/EhBZSdvX4Ur12PhO7l4p0iW8nsxm2A bfZmFJ5OwL2s4qrQzbY8koUmz; Received: from 97-122-68-246.hlrn.qwest.net ([97.122.68.246]:54168 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mnLkp-001jo5-SV; Wed, 17 Nov 2021 07:17:39 -0700 From: Tom Tromey To: Aaron Merey via Gdb-patches Cc: simon.marchi@polymtl.ca, Aaron Merey , tom@tromey.com, lsix@lancelotsix.com Subject: Re: [PATCH 2/3] gdb: Add soname to build-id mapping for corefiles References: <20211117032441.719270-1-amerey@redhat.com> X-Attribution: Tom Date: Wed, 17 Nov 2021 07:17:38 -0700 In-Reply-To: <20211117032441.719270-1-amerey@redhat.com> (Aaron Merey via Gdb-patches's message of "Tue, 16 Nov 2021 22:24:41 -0500") Message-ID: <877dd6euil.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.68.246 X-Source-L: No X-Exim-ID: 1mnLkp-001jo5-SV X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-246.hlrn.qwest.net (murgatroyd) [97.122.68.246]:54168 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3022.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS_A autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Wed, 17 Nov 2021 14:22:07 -0000 >>>>> "Aaron" =3D=3D Aaron Merey via Gdb-patches writes: >> Can you explain why we are opening bfd->filename? =C2=A0Doesn't "abfd" >> represent the exact same thing than "bfd"? =C2=A0So why can't we use "bf= d" >> directly to look up the soname? Aaron> bfd->flags does not contain the correct value. This causes the check Aaron> for ET_DYN to fail even for shared libraries. Also bfd->build_id al= ways Aaron> seems to be NULL. Opening "abfd" with gdb_bfd_open and passing it to Aaron> bfd_check_format populates flags and build_id with the correct value= s. Aaron> Passing "bfd" to bfd_check_format still does not populate these fiel= ds Aaron> with the correct values. Aaron> It looks like this happens because the format of "abfd" is initially Aaron> set to bfd_unknown. In this case bfd_check_format rereads the file = and Aaron> updates some fields with the correct values, including flags and bui= ld_id. Aaron> Since format of "bfd" is instead bfd_object, bfd_check_format returns Aaron> early and skips updating any fields. This seems strange to me. At first I was surprised that re-opening the BFD like this wouldn't simply return the same BFD, since gdb uses a BFD cache. However, now I see that corelow isn't using the cache: bfd =3D bfd_map[filename] =3D bfd_openr (expanded_fname.get (), "binary"); (as opposed to using gdb_bfd_openr here.) If re-opening and then calling bfd_check_format sets the flags correctly, then I suppose the question is just why the call in build_file_mappings isn't doing that: if (bfd =3D=3D nullptr || !bfd_check_format (bfd, bfd_object)) Possibly the answer is that corelow passes "binary" as the target, but your code does: Aaron> + gdb_bfd_ref_ptr abfd =3D gdb_bfd_open (bfd->filename, gnutarget); But then I wonder why "binary" is appropriate in corelow. Tom