]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add one judge whether TeImage or PeImage has reloc section when relocate TeImage...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Oct 2007 09:28:29 +0000 (09:28 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Oct 2007 09:28:29 +0000 (09:28 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4224 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Pei/Image/Image.c
MdePkg/Library/BasePeCoffLib/BasePeCoff.c

index c9805f53113f25b198dc5afd7b5d3646b91e5a34..c38fa56705d98f8ad2073fca42a629c97dad99cb 100644 (file)
@@ -238,6 +238,13 @@ Returns:
     return Status;\r
   }\r
   //\r
+  // When Image has no reloc section, it can't be relocated into memory.\r
+  //\r
+  if (ImageContext.RelocationsStripped) {\r
+    DEBUG ((EFI_D_ERROR, "The image at 0x%08x without reloc section can't be loaded into memory", (UINTN) Pe32Data));\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
   // Allocate Memory for the image\r
   //\r
   ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) AllocatePages (EFI_SIZE_TO_PAGES ((UINT32) ImageContext.ImageSize));\r
index fb78aefb8cd871720ca355e9e8400acb53a65a70..dbdb5ab869aa8e9af1792c8895dbf8636d362d0b 100644 (file)
@@ -271,6 +271,8 @@ PeCoffLoaderGetImageInfo (
   //\r
   if ((!(ImageContext->IsTeImage)) && ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) {\r
     ImageContext->RelocationsStripped = TRUE;\r
+  } else if ((ImageContext->IsTeImage) && (Hdr.Te->DataDirectory[0].Size == 0) && (Hdr.Te->DataDirectory[0].VirtualAddress == 0)) {\r
+    ImageContext->RelocationsStripped = TRUE;\r
   } else {\r
     ImageContext->RelocationsStripped = FALSE;\r
   }\r