From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in6.apple.com (mail-out6.apple.com [17.151.62.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 9051721D490F4 for ; Thu, 10 Aug 2017 22:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1502428078; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NQ2ub8BjBriDg3Un9yvABB9lhUtmOIdvCualSGMqNog=; b=decxxef5+7Q0a5Z/HdDWhSGBmfbJ+kkuWTyyOb+FOMLz9Uc1vg26J594QSlmFxrA dMSTD+7JQ8Ee7vba74YaIUAPnmizUUE8HOr/vTOE3Km3rJRlV1DrnJNo6LmK4zjb 8+Q2Wuh6f6poWt8INYbHpLH7+7wdGky/CV4lxHgyR7BoNJv1UWXtTl72KcOi+uxb sTsfmXfc6qcd0ApcO/veWbon8HlMXuuS2ULxDj6xtVmdqiLDE+8Ek8xBWUiMHs7N t1tU4D5cW/TXp2S1SBFbtYPOfyyJdlomXh22YOkGhnWLV/dVSYDHPDMOosM/J969 tsisRpUzPaZlgsjaUQfAYg==; Received: from relay21.apple.com (relay21.apple.com [17.171.128.102]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in6.apple.com (Apple Secure Mail Relay) with SMTP id 5C.DE.06961.DAB3D895; Thu, 10 Aug 2017 22:07:58 -0700 (PDT) X-AuditID: 11973e15-9dace9c000001b31-b2-598d3badfb03 Received: from ma1-mmpp-sz07.apple.com (ma1-mmpp-sz07.apple.com [17.171.128.149]) by relay21.apple.com (Apple SCV relay) with SMTP id 45.1D.09656.AAB3D895; Thu, 10 Aug 2017 22:07:54 -0700 (PDT) MIME-version: 1.0 Received: from [17.234.229.108] by ma1-mmpp-sz07.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170621 64bit (built Jun 21 2017)) with ESMTPSA id <0OUI00EN08X3DV60@ma1-mmpp-sz07.apple.com>; Thu, 10 Aug 2017 22:07:54 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: <4A89E2EF3DFEDB4C8BFDE51014F606A14D76E5FF@shsmsx102.ccr.corp.intel.com> Date: Thu, 10 Aug 2017 22:07:51 -0700 Cc: Mike Kinney , "edk2-devel@lists.01.org" Message-id: <6B474862-80FC-4D7B-B732-D10F791182F5@apple.com> References: <1502078429-13340-1-git-send-email-yonghong.zhu@intel.com> <5BC1C303-CE42-4DAD-91EB-F4BB327DE88A@apple.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14D76DAD8@shsmsx102.ccr.corp.intel.com> <2AC68977-AB40-45DC-B97D-27FFCE19C155@apple.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14D76E5FF@shsmsx102.ccr.corp.intel.com> To: "Gao, Liming" X-Mailer: Apple Mail (2.3273) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrALMWRmVeSWpSXmKPExsUiuLohTXeddW+kwf/7QhZ7Dh1ltlhxbwO7 RUfHPyYHZo/Fe14yeXTP/scSwBTFZZOSmpNZllqkb5fAlXF5zUGWgqNWFZP+3GFtYDyp38XI ySEhYCJxtukWC4gtJLCOSeLr5SiY+I72PexdjFxA8cOMEq/OvQQr4hUQlPgx+R6QzcHBLCAv cfC8LEiYWUBL4vujVhaI+m+MEotmfGEGSQgLiEu8O7MJyk6U+DzzMxOIzSagLLFi/gd2EJtT IEzi79GXrCA2i4CqxJmdV5gghiZLTFt0gh1ir43EwxdTGSEWHGCS+L+mD6xBREBD4uG938wQ V8tK3Jp9iR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jlM9YfUWIpzkg01GIuKk4EAD5q p3ZIAgAA Subject: Re: [Patch] BaseTools: Fix Segmentation fault: 11 when build AppPkg with XCODE5 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: Fri, 11 Aug 2017 05:05:39 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Aug 10, 2017, at 9:48 PM, Gao, Liming wrote: > > Andrew: > Edk2 Build system calls GenFw to generate EFI image in build phase. Even if this image is not built into BIOS image, its EFI image will be generated by GenFw. So, only if this EFI image is built from EDK2 project, it can be updated by GenFw tool. You can see this step in build_rule.txt to convert .dll to .efi image. > Gao, We can fix the future for edk2, but we can't change the past, or change other build systems. It is not safe to assume that every EFI executable that the DXE Core will see is as new as the firmware, or was even built via the edk2. Option ROMs and OS loaders are good examples of this issue. Thanks, Andrew Fish > Thanks > Liming > From: afish@apple.com [mailto:afish@apple.com] > Sent: Friday, August 11, 2017 12:59 AM > To: Gao, Liming > Cc: Zhu, Yonghong ; Kinney, Michael D ; edk2-devel@lists.01.org > Subject: Re: [edk2] [Patch] BaseTools: Fix Segmentation fault: 11 when build AppPkg with XCODE5 > > > On Aug 10, 2017, at 3:38 AM, Gao, Liming > wrote: > > Andrew: > If this is a mtoc bug, I suggest to update GenFw to always correct it in the generated EFI image. If so, the EFI image is always correct. There is no change requirement in PeCoff library in MdePkg. > > > Liming, > > EFI supports loading PE/COFF images that are not built at the same time as the platform firmware (UEFI Shell, OS loader), and that is why I added the fix to the PE/COFF library code. > > Thanks, > > Andrew Fish > > > Thanks > Liming > From: afish@apple.com [mailto:afish@apple.com] > Sent: Tuesday, August 8, 2017 12:26 AM > To: Zhu, Yonghong > > Cc: edk2-devel@lists.01.org; Gao, Liming >; Kinney, Michael D > > Subject: Re: [Patch] BaseTools: Fix Segmentation fault: 11 when build AppPkg with XCODE5 > > Should that be: > Contributed-under: TianoCore Contribution Agreement 1.1 > > I also noticed the PeCoff lib is going to loop and reload the .debug suction due to this mtoc bug, so it would be good to harden that code too. > > git diff MdePkg/Library/BasePeCoffLib/BasePeCoff.c > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > index 8d1daba..1e4c67e 100644 > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > @@ -771,6 +771,8 @@ PeCoffLoaderGetImageInfo ( > } > > return RETURN_SUCCESS; > + } else if (DebugEntry.Type == CODEVIEW_SIGNATURE_MTOC) { > + return RETURN_SUCCESS; > } > } > } > @@ -862,6 +864,8 @@ PeCoffLoaderGetImageInfo ( > if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { > ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index); > return RETURN_SUCCESS; > + } else if (DebugEntry.Type == CODEVIEW_SIGNATURE_MTOC) { > + return RETURN_SUCCESS; > } > } > } > > > > https://bugzilla.tianocore.org/show_bug.cgi?id=663 > Contributed-under: TianoCore Contribution Agreement 1.1 > > Thanks, > > Andrew Fish > > > On Aug 6, 2017, at 9:00 PM, Yonghong Zhu > wrote: > > it is a bug in mtoc setting the size of the debug directory entry to > the size of the .debug section, not the size of the > EFI_IMAGE_DEBUG_DIRECTORY_ENTRY. It was causing a loop to iterate and > get bogus EFI_IMAGE_DEBUG_DIRECTORY_ENTRY data and pass that to > memset() and boom. > > Cc: Liming Gao > > Cc: Michael D Kinney > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Andrew Fish > > --- > BaseTools/Source/C/GenFw/GenFw.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c > index 246deb0..af60c92 100644 > --- a/BaseTools/Source/C/GenFw/GenFw.c > +++ b/BaseTools/Source/C/GenFw/GenFw.c > @@ -2813,10 +2813,11 @@ Returns: > // > // Get Debug, Export and Resource EntryTable RVA address. > // Resource Directory entry need to review. > // > Optional32Hdr = (EFI_IMAGE_OPTIONAL_HEADER32 *) ((UINT8*) FileHdr + sizeof (EFI_IMAGE_FILE_HEADER)); > + Optional64Hdr = (EFI_IMAGE_OPTIONAL_HEADER64 *) ((UINT8*) FileHdr + sizeof (EFI_IMAGE_FILE_HEADER)); > if (Optional32Hdr->Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { > SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) Optional32Hdr + FileHdr->SizeOfOptionalHeader); > if (Optional32Hdr->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_EXPORT && \ > Optional32Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT].Size != 0) { > ExportDirectoryEntryRva = Optional32Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; > @@ -2833,11 +2834,10 @@ Returns: > Optional32Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = 0; > Optional32Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress = 0; > } > } > } else { > - Optional64Hdr = (EFI_IMAGE_OPTIONAL_HEADER64 *) ((UINT8*) FileHdr + sizeof (EFI_IMAGE_FILE_HEADER)); > SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) Optional64Hdr + FileHdr->SizeOfOptionalHeader); > if (Optional64Hdr->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_EXPORT && \ > Optional64Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT].Size != 0) { > ExportDirectoryEntryRva = Optional64Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; > } > @@ -2907,10 +2907,20 @@ Returns: > RsdsEntry->Unknown = 0; > RsdsEntry->Unknown2 = 0; > RsdsEntry->Unknown3 = 0; > RsdsEntry->Unknown4 = 0; > RsdsEntry->Unknown5 = 0; > + } else if (RsdsEntry->Signature == CODEVIEW_SIGNATURE_MTOC) { > + // MTOC sets DebugDirectoryEntrySize to size of the .debug section, so fix it. > + if (!ZeroDebugFlag) { > + if (Optional32Hdr->Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { > + Optional32Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); > + } else { > + Optional64Hdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); > + } > + } > + break; > } > } > } > } > > -- > 2.6.1.windows.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel