From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Laszlo Ersek <lersek@redhat.com>
Cc: edk2-devel-01 <edk2-devel@lists.01.org>,
Gerd Hoffmann <kraxel@redhat.com>,
Leif Lindholm <leif.lindholm@linaro.org>,
Liming Gao <liming.gao@intel.com>,
Yonghong Zhu <yonghong.zhu@intel.com>
Subject: Re: [PATCH] BaseTools/GenFw: work around GNU Binutils bug wrt. DebugDirectoryEntrySize
Date: Wed, 5 Jul 2017 18:37:50 +0100 [thread overview]
Message-ID: <CAKv+Gu-wZhFbEBfqSTnP59ORJbOZEN6=FRR7NxjnFBt3s6p1zw@mail.gmail.com> (raw)
In-Reply-To: <efb1167e-9bd2-556f-b752-869516b4691e@redhat.com>
On 5 July 2017 at 18:33, Laszlo Ersek <lersek@redhat.com> wrote:
> On 07/05/17 18:45, Ard Biesheuvel wrote:
>> On 5 July 2017 at 17:42, Laszlo Ersek <lersek@redhat.com> 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?
next prev parent reply other threads:[~2017-07-05 17:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-05 16:42 [PATCH] BaseTools/GenFw: work around GNU Binutils bug wrt. DebugDirectoryEntrySize Laszlo Ersek
2017-07-05 16:45 ` Ard Biesheuvel
2017-07-05 17:28 ` Laszlo Ersek
2017-07-05 17:33 ` Ard Biesheuvel
2017-07-05 17:49 ` Laszlo Ersek
2017-07-05 17:33 ` Laszlo Ersek
2017-07-05 17:37 ` Ard Biesheuvel [this message]
2017-07-05 17:52 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKv+Gu-wZhFbEBfqSTnP59ORJbOZEN6=FRR7NxjnFBt3s6p1zw@mail.gmail.com' \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox