From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 124A1385B835 for ; Thu, 16 Apr 2020 19:21:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 124A1385B835 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-36-WPtz8_DgP1SdZ6nDKCnmJw-1; Thu, 16 Apr 2020 15:21:52 -0400 X-MC-Unique: WPtz8_DgP1SdZ6nDKCnmJw-1 Received: by mail-wr1-f69.google.com with SMTP id m5so2233840wru.15 for ; Thu, 16 Apr 2020 12:21:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=s5l2cY1kHyuNg0+OV+ouD74c/y+I56LE/FHtTTD8lK0=; b=VlTe4S77ydkjVTGNFr/DK+Aum1Pdpb5M/YU090i7gzz6whvYIGbcuNwNgXfaueL77G NQ/EHjDxZu53hsv7O21D47K7VqjPU1H0vun1t8sMMP8QPOwYepg8LDxwy/WcfXKacCnM Irj13KBNiI09kgCc8H+wpo3lIT38uMTP2NpHecj8mxgAkXGF1kgb1ZjxavAaG8kz4bso S/WrrB2vJt4aQ68JEp3Exx9QPhP+47Aq7OAgL+SdcnFxw7VwlrXzGgICvmvvR2MjTdBp wNPjqqj1anRJF2W3yd4jlBHqhKdkPSb/MJtUv5DUhqr4iGnI5//MbHCdwkjTzlCeQTIs sO5Q== X-Gm-Message-State: AGi0Pub5YZNza+ToJkkhsOJKdHdl7uzrOC2PppyuSHj5kQd4TFj1r5dm og0RntVZpJZk5PS2RbVCIbh9bhNAVSc5BJYGa/+LA9+wV4SrvOsK1jAqfMtOb+SfbBkkSsg9tep MqyTm+WxBTYYNZ4VTnKoVrg== X-Received: by 2002:adf:f282:: with SMTP id k2mr18310238wro.133.1587064911407; Thu, 16 Apr 2020 12:21:51 -0700 (PDT) X-Google-Smtp-Source: APiQypJP56f52KL1duM5AhLux0yqYvjDM7gdIT1Kus3XC5XgOiqjHWVilGsIlZGPYK+SAthwymA6og== X-Received: by 2002:adf:f282:: with SMTP id k2mr18310220wro.133.1587064911213; Thu, 16 Apr 2020 12:21:51 -0700 (PDT) Received: from ?IPv6:2001:8a0:f909:7b00:56ee:75ff:fe8d:232b? ([2001:8a0:f909:7b00:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id r20sm4528746wmh.26.2020.04.16.12.21.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Apr 2020 12:21:50 -0700 (PDT) Subject: Re: [PATCH v2 1/2] gdb: make is_linked_with_cygwin_dll handle import table not at beginning of .idata section To: Simon Marchi , gdb-patches@sourceware.org References: <20200416154508.168585-1-simon.marchi@polymtl.ca> <20200416184739.205859-1-simon.marchi@polymtl.ca> From: Pedro Alves Message-ID: Date: Thu, 16 Apr 2020 20:21:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20200416184739.205859-1-simon.marchi@polymtl.ca> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Thu, 16 Apr 2020 19:21:56 -0000 On 4/16/20 7:47 PM, Simon Marchi via Gdb-patches wrote: > When loading the file C:\Windows\SysWOW64\msvcrt.dll, taken from a > Windows 10 system, into GDB, we get the following warning: > > warning: Failed to parse .idata section: name's virtual address (0x0) is outside .idata section's range [0xb82b8, 0xb97f0[. > > This uncovers an issue with how we parse the import table, part of the > .idata section. Right now, we assume that the import table is located > at the beginning of the section. That was the case in everything I had > tried so far, but this file is an example where that's not true. > > We need to compute the offset of the import table within the .idata > section, and start there, instead of at the beginning of the .idata > section. Using the file mentioned above, this is the values we have to > work with: > > A) bfd_section_vma (idata_section) 101b8000 > B) Import table's virtual address b82b8 > C) Image base 10100000 > > The virtual address that BFD returns us for the section has the image > base applied, so we need to subtract it first. The offset of the table > in the section is therefore: > > B - (A - C) > > This patch implements that. > > gdb/ChangeLog: > > windows-tdep.c (is_linked_with_cygwin_dll): Consider case where > import table is not at beginning of .idata section. Note the missing leading '*'. This version looks good to me. Both patches. Thanks, Pedro Alves