diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index 7c839e277944..db0978d4089d 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -3500,63 +3500,63 @@ Returns:
     //
     if (ImageContext.RelocationsStripped) {
       Warning (NULL, 0, 0, "Invalid", "The file %s has no .reloc section.", FileName);
-      continue;
-    }
+    } else {
 
-    //
-    // Relocation exist and rebase
-    //
-    //
-    // Load and Relocate Image Data
-    //
-    MemoryImagePointer = (UINT8 *) malloc ((UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
-    if (MemoryImagePointer == NULL) {
-      Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);
-      return EFI_OUT_OF_RESOURCES;
-    }
-    memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
-    ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((UINTN) ImageContext.SectionAlignment - 1));
-    
-    Status =  PeCoffLoaderLoadImage (&ImageContext);
-    if (EFI_ERROR (Status)) {
-      Error (NULL, 0, 3000, "Invalid", "LocateImage() call failed on rebase of %s", FileName);
-      free ((VOID *) MemoryImagePointer);
-      return Status;
-    }
-         
-    ImageContext.DestinationAddress = NewPe32BaseAddress;
-    Status                          = PeCoffLoaderRelocateImage (&ImageContext);
-    if (EFI_ERROR (Status)) {
-      Error (NULL, 0, 3000, "Invalid", "RelocateImage() call failed on rebase of %s", FileName);
-      free ((VOID *) MemoryImagePointer);
-      return Status;
-    }
+      //
+      // Relocation exist and rebase
+      //
+      //
+      // Load and Relocate Image Data
+      //
+      MemoryImagePointer = (UINT8 *) malloc ((UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
+      if (MemoryImagePointer == NULL) {
+        Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);
+        return EFI_OUT_OF_RESOURCES;
+      }
+      memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
+      ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((UINTN) ImageContext.SectionAlignment - 1));
 
-    //
-    // Copy Relocated data to raw image file.
-    //
-    SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (
-                       (UINTN) ImgHdr +
-                       sizeof (UINT32) + 
-                       sizeof (EFI_IMAGE_FILE_HEADER) +  
-                       ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader
-                       );
-    
-    for (Index = 0; Index < ImgHdr->Pe32.FileHeader.NumberOfSections; Index ++, SectionHeader ++) {
-      CopyMem (
-        (UINT8 *) CurrentPe32Section.Pe32Section + CurSecHdrSize + SectionHeader->PointerToRawData, 
-        (VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress), 
-        SectionHeader->SizeOfRawData
-        );
-    }
+      Status =  PeCoffLoaderLoadImage (&ImageContext);
+      if (EFI_ERROR (Status)) {
+        Error (NULL, 0, 3000, "Invalid", "LocateImage() call failed on rebase of %s", FileName);
+        free ((VOID *) MemoryImagePointer);
+        return Status;
+      }
 
-    free ((VOID *) MemoryImagePointer);
-    MemoryImagePointer = NULL;
-    if (PeFileBuffer != NULL) {
-      free (PeFileBuffer);
-      PeFileBuffer = NULL;
+      ImageContext.DestinationAddress = NewPe32BaseAddress;
+      Status                          = PeCoffLoaderRelocateImage (&ImageContext);
+      if (EFI_ERROR (Status)) {
+        Error (NULL, 0, 3000, "Invalid", "RelocateImage() call failed on rebase of %s", FileName);
+        free ((VOID *) MemoryImagePointer);
+        return Status;
+      }
+
+      //
+      // Copy Relocated data to raw image file.
+      //
+      SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (
+                         (UINTN) ImgHdr +
+                         sizeof (UINT32) +
+                         sizeof (EFI_IMAGE_FILE_HEADER) +
+                         ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader
+                         );
+
+      for (Index = 0; Index < ImgHdr->Pe32.FileHeader.NumberOfSections; Index ++, SectionHeader ++) {
+        CopyMem (
+          (UINT8 *) CurrentPe32Section.Pe32Section + CurSecHdrSize + SectionHeader->PointerToRawData,
+          (VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress),
+          SectionHeader->SizeOfRawData
+          );
+      }
+
+      free ((VOID *) MemoryImagePointer);
+      MemoryImagePointer = NULL;
+      if (PeFileBuffer != NULL) {
+        free (PeFileBuffer);
+        PeFileBuffer = NULL;
+      }
     }
-    
+
     //
     // Update Image Base Address
     //
@@ -3730,70 +3730,69 @@ Returns:
     //
     if (ImageContext.RelocationsStripped) {
       Warning (NULL, 0, 0, "Invalid", "The file %s has no .reloc section.", FileName);
-      continue;
-    }
+    } else {
+      //
+      // Relocation exist and rebase
+      //
+      //
+      // Load and Relocate Image Data
+      //
+      MemoryImagePointer = (UINT8 *) malloc ((UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
+      if (MemoryImagePointer == NULL) {
+        Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);
+        return EFI_OUT_OF_RESOURCES;
+      }
+      memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
+      ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((UINTN) ImageContext.SectionAlignment - 1));
 
-    //
-    // Relocation exist and rebase
-    //
-    //
-    // Load and Relocate Image Data
-    //
-    MemoryImagePointer = (UINT8 *) malloc ((UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
-    if (MemoryImagePointer == NULL) {
-      Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);
-      return EFI_OUT_OF_RESOURCES;
-    }
-    memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
-    ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((UINTN) ImageContext.SectionAlignment - 1));
+      Status =  PeCoffLoaderLoadImage (&ImageContext);
+      if (EFI_ERROR (Status)) {
+        Error (NULL, 0, 3000, "Invalid", "LocateImage() call failed on rebase of %s", FileName);
+        free ((VOID *) MemoryImagePointer);
+        return Status;
+      }
+      //
+      // Relocate TeImage
+      //
+      ImageContext.DestinationAddress = NewPe32BaseAddress;
+      Status                          = PeCoffLoaderRelocateImage (&ImageContext);
+      if (EFI_ERROR (Status)) {
+        Error (NULL, 0, 3000, "Invalid", "RelocateImage() call failed on rebase of TE image %s", FileName);
+        free ((VOID *) MemoryImagePointer);
+        return Status;
+      }
 
-    Status =  PeCoffLoaderLoadImage (&ImageContext);
-    if (EFI_ERROR (Status)) {
-      Error (NULL, 0, 3000, "Invalid", "LocateImage() call failed on rebase of %s", FileName);
-      free ((VOID *) MemoryImagePointer);
-      return Status;
-    }
-    //
-    // Reloacate TeImage
-    // 
-    ImageContext.DestinationAddress = NewPe32BaseAddress;
-    Status                          = PeCoffLoaderRelocateImage (&ImageContext);
-    if (EFI_ERROR (Status)) {
-      Error (NULL, 0, 3000, "Invalid", "RelocateImage() call failed on rebase of TE image %s", FileName);
+      //
+      // Copy the relocated image into raw image file.
+      //
+      SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (TEImageHeader + 1);
+      for (Index = 0; Index < TEImageHeader->NumberOfSections; Index ++, SectionHeader ++) {
+        if (!ImageContext.IsTeImage) {
+          CopyMem (
+            (UINT8 *) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->PointerToRawData,
+            (VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress),
+            SectionHeader->SizeOfRawData
+            );
+        } else {
+          CopyMem (
+            (UINT8 *) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->PointerToRawData,
+            (VOID*) (UINTN) (ImageContext.ImageAddress + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->VirtualAddress),
+            SectionHeader->SizeOfRawData
+            );
+        }
+      }
+
+      //
+      // Free the allocated memory resource
+      //
       free ((VOID *) MemoryImagePointer);
-      return Status;
-    }
-    
-    //
-    // Copy the relocated image into raw image file.
-    //
-    SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (TEImageHeader + 1);
-    for (Index = 0; Index < TEImageHeader->NumberOfSections; Index ++, SectionHeader ++) {
-      if (!ImageContext.IsTeImage) {
-        CopyMem (
-          (UINT8 *) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->PointerToRawData, 
-          (VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress), 
-          SectionHeader->SizeOfRawData
-          );
-      } else {
-        CopyMem (
-          (UINT8 *) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->PointerToRawData, 
-          (VOID*) (UINTN) (ImageContext.ImageAddress + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->VirtualAddress), 
-          SectionHeader->SizeOfRawData
-          );
+      MemoryImagePointer = NULL;
+      if (PeFileBuffer != NULL) {
+        free (PeFileBuffer);
+        PeFileBuffer = NULL;
       }
     }
-    
-    //
-    // Free the allocated memory resource
-    //
-    free ((VOID *) MemoryImagePointer);
-    MemoryImagePointer = NULL;
-    if (PeFileBuffer != NULL) {
-      free (PeFileBuffer);
-      PeFileBuffer = NULL;
-    }
-    
+
     //
     // Update Image Base Address
     //
