]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BasePeCoffLib/BasePeCoff.c
1. UINTN & INTN issue for EBC architecture:
[mirror_edk2.git] / MdePkg / Library / BasePeCoffLib / BasePeCoff.c
index e91e9a6c2ff089071887069ae0999c9dd60e8978..32a70c00c46d1fec385a294b01bbf4a96d406309 100644 (file)
 \r
 **/\r
 \r
+/**\r
+  Performs an Itanium-based specific relocation fixup.\r
 \r
+  @param  Reloc       Pointer to the relocation record.\r
+  @param  Fixup       Pointer to the address to fix up.\r
+  @param  FixupData   Pointer to a buffer to log the fixups.\r
+  @param  Adjust      The offset to adjust the fixup.\r
 \r
+  @return Status code.\r
 \r
-STATIC\r
-RETURN_STATUS\r
-PeCoffLoaderGetPeHeader (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
-  OUT    EFI_IMAGE_NT_HEADERS          *PeHdr,\r
-  OUT    EFI_TE_IMAGE_HEADER           *TeHdr\r
-  );\r
-\r
-STATIC\r
-RETURN_STATUS\r
-PeCoffLoaderCheckImageType (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
-  IN     EFI_IMAGE_NT_HEADERS          *PeHdr,\r
-  IN     EFI_TE_IMAGE_HEADER           *TeHdr\r
-  );\r
-\r
-STATIC\r
-VOID *\r
-PeCoffLoaderImageAddress (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
-  IN     UINTN                         Address\r
-  );\r
-\r
+**/\r
 RETURN_STATUS\r
 PeCoffLoaderRelocateImageEx (\r
   IN UINT16      *Reloc,\r
@@ -193,11 +178,9 @@ PeCoffLoaderCheckImageType (
   @param  ImageContext              Pointer to the image context structure that describes the PE/COFF\r
                                     image that needs to be examined by this function.\r
 \r
-  @retval  RETURN_SUCCESS           The information on the PE/COFF image was collected.\r
-  @retval  RETURN_INVALID_PARAMETER ImageContext is NULL.\r
-  @retval  RETURN_UNSUPPORTED       The PE/COFF image is not supported.\r
-  @retval  Others                   The error status from reading the PE/COFF image\r
-                                    using the ImageContext->ImageRead() function.\r
+  @retval RETURN_SUCCESS            The information on the PE/COFF image was collected.\r
+  @retval RETURN_INVALID_PARAMETER  ImageContext is NULL.\r
+  @retval RETURN_UNSUPPORTED        The PE/COFF image is not supported.\r
 \r
 **/\r
 RETURN_STATUS\r
@@ -687,6 +670,7 @@ PeCoffLoaderRelocateImage (
   specified by the ImageAddress and ImageSize fields of ImageContext.  The caller must allocate\r
   the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.\r
   The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.\r
+  If ImageContext is NULL, then ASSERT().\r
 \r
   @param  ImageContext              Pointer to the image context structure that describes the PE/COFF\r
                                     image that is being loaded.\r
@@ -724,8 +708,11 @@ PeCoffLoaderLoadImage (
   UINTN                                 Size;\r
   UINT32                                TempDebugEntryRva;\r
 \r
+  ASSERT (ImageContext != NULL);\r
+\r
   PeHdr = NULL;\r
   TeHdr = NULL;\r
+\r
   //\r
   // Assume success\r
   //\r
@@ -750,7 +737,13 @@ PeCoffLoaderLoadImage (
     ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_SIZE;\r
     return RETURN_BUFFER_TOO_SMALL;\r
   }\r
-\r
+  if (ImageContext->ImageAddress == 0) {\r
+    //\r
+    // Image cannot be loaded into 0 address.\r
+    //\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
   //\r
   // If there's no relocations, then make sure it's not a runtime driver,\r
   // and that it's being loaded at the linked address.\r