+/**\r
+ Check whether the input image has the relocation.\r
+\r
+ @param Pe32Data Pointer to the PE/COFF or TE image.\r
+\r
+ @retval TRUE Relocation is stripped.\r
+ @retval FALSE Relocation is not stripped.\r
+\r
+**/\r
+BOOLEAN\r
+RelocationIsStrip (\r
+ IN VOID *Pe32Data\r
+ )\r
+{\r
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;\r
+ EFI_IMAGE_DOS_HEADER *DosHdr;\r
+\r
+ ASSERT (Pe32Data != NULL);\r
+\r
+ DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
+ if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+ //\r
+ // DOS image header is present, so read the PE header after the DOS image header.\r
+ //\r
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
+ } else {\r
+ //\r
+ // DOS image header is not present, so PE header is at the image base.\r
+ //\r
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;\r
+ }\r
+\r
+ //\r
+ // Three cases with regards to relocations:\r
+ // - Image has base relocs, RELOCS_STRIPPED==0 => image is relocatable\r
+ // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable\r
+ // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but\r
+ // has no base relocs to apply\r
+ // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid.\r
+ //\r
+ // Look at the file header to determine if relocations have been stripped, and\r
+ // save this info in the image context for later use.\r
+ //\r
+ if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+ if ((Hdr.Te->DataDirectory[0].Size == 0) && (Hdr.Te->DataDirectory[0].VirtualAddress == 0)) {\r
+ return TRUE;\r
+ } else {\r
+ return FALSE;\r
+ }\r
+ } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
+ if ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0) {\r
+ return TRUE;\r
+ } else {\r
+ return FALSE;\r
+ }\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r