diff options
author | Andrew Fish <afish@apple.com> | 2017-08-07 11:26:05 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2017-08-14 15:41:40 +0800 |
commit | 0024172d909ec73a9ce9ffdfc9fdd4382080e110 (patch) | |
tree | 73e3bdb0d33aa17dbce9cc91c98227ab037bc495 /BaseTools/Source/C/GenFw/GenFw.c | |
parent | 7b1dbd15ea00d09f5e8b1fe0f6c97f1eba0f7efe (diff) | |
download | edk2-0024172d909ec73a9ce9ffdfc9fdd4382080e110.tar.gz edk2-0024172d909ec73a9ce9ffdfc9fdd4382080e110.tar.bz2 edk2-0024172d909ec73a9ce9ffdfc9fdd4382080e110.zip |
BaseTools: Fix Segmentation fault: 11 when build AppPkg with XCODE5
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 <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Andrew Fish <afish@apple.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/C/GenFw/GenFw.c')
-rw-r--r-- | BaseTools/Source/C/GenFw/GenFw.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c index 246deb0344..af60c92763 100644 --- a/BaseTools/Source/C/GenFw/GenFw.c +++ b/BaseTools/Source/C/GenFw/GenFw.c @@ -2815,6 +2815,7 @@ Returns: // 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 && \
@@ -2835,7 +2836,6 @@ Returns: }
}
} 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) {
@@ -2909,6 +2909,16 @@ Returns: 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;
}
}
}
|