From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9EB9C2095896E for ; Wed, 5 Jul 2017 10:50:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B35533B721; Wed, 5 Jul 2017 17:52:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B35533B721 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B35533B721 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-25.phx2.redhat.com [10.3.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8284C17104; Wed, 5 Jul 2017 17:52:24 +0000 (UTC) To: Ard Biesheuvel Cc: edk2-devel-01 , Gerd Hoffmann , Leif Lindholm , Liming Gao , Yonghong Zhu References: <20170705164218.25814-1-lersek@redhat.com> From: Laszlo Ersek Message-ID: <223c0192-f2ca-486e-545c-eb03de306b1e@redhat.com> Date: Wed, 5 Jul 2017 19:52:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 05 Jul 2017 17:52:27 +0000 (UTC) Subject: Re: [PATCH] BaseTools/GenFw: work around GNU Binutils bug wrt. DebugDirectoryEntrySize X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jul 2017 17:50:48 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 07/05/17 19:37, Ard Biesheuvel wrote: > On 5 July 2017 at 18:33, Laszlo Ersek wrote: >> On 07/05/17 18:45, Ard Biesheuvel wrote: >>> On 5 July 2017 at 17:42, Laszlo Ersek wrote: >>>> GNU Binutils produce a PE debug directory with one >>> >>> This sentence already confuses me. This crash is reproducible on ARM, >>> but the ARM toolchains are strictly ELF based, and all PE/COFF data >>> structures are created by GenFw itself, never by binutils. So I don't >>> see how this could be a binutils bug. >> >> Geez, you are totally right. From >> "BaseTools/Source/C/GenFw/Elf64Convert.c": >> >> >>> STATIC >>> VOID >>> WriteDebug64 ( >>> VOID >>> ) >>> { >>> UINT32 Len; >>> EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr; >>> EFI_IMAGE_DATA_DIRECTORY *DataDir; >>> EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *Dir; >>> EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY *Nb10; >>> >>> Len = strlen(mInImageName) + 1; >>> >>> Dir = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY*)(mCoffFile + mDebugOffset); >>> Dir->Type = EFI_IMAGE_DEBUG_TYPE_CODEVIEW; >>> Dir->SizeOfData = sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) + Len; >>> Dir->RVA = mDebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); >>> Dir->FileOffset = mDebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); >>> >>> Nb10 = (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY*)(Dir + 1); >>> Nb10->Signature = CODEVIEW_SIGNATURE_NB10; >>> strcpy ((char *)(Nb10 + 1), mInImageName); >>> >>> >>> NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(mCoffFile + mNtHdrOffset); >>> DataDir = &NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]; >>> DataDir->VirtualAddress = mDebugOffset; >>> DataDir->Size = Dir->SizeOfData + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); >>> } >> >> The last assignment has the bug. It should be >> >> DataDir->Size = sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); >> > > OK, I will take that as an affirmative answer to my question. Are you > sending a patch? > You send it please, just give me some "Co-debugged-by:" or whatever. :) Also, please add a ref to the mailing list thread. Thanks! Laszlo