Index: /trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/Library/VBoxPeCoffLib/BasePeCoff.c
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/Library/VBoxPeCoffLib/BasePeCoff.c	(revision 38951)
+++ /trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/Library/VBoxPeCoffLib/BasePeCoff.c	(revision 38952)
@@ -710,114 +710,118 @@
 
   //
-  // Run the relocation information and apply the fixups
-  //
-  FixupData = ImageContext->FixupData;
-  while (RelocBase < RelocBaseEnd) {
-
-    Reloc     = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));
-    RelocEnd  = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
-
-    //
-    // Make sure RelocEnd is in the Image range.
-    //
-    if ((CHAR8 *) RelocEnd < (CHAR8 *)((UINTN) ImageContext->ImageAddress) ||
-        (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress + (UINTN)ImageContext->ImageSize)) {
-      ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
-      return RETURN_LOAD_ERROR;
-    }
-
-    if (!(ImageContext->IsTeImage)) {
-      FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
-      if (FixupBase == NULL) {
+  // If Adjust is not zero, then apply fix ups to the image
+  //
+  if (Adjust != 0) {
+    //
+    // Run the relocation information and apply the fixups
+    //
+    FixupData = ImageContext->FixupData;
+    while (RelocBase < RelocBaseEnd) {
+
+      Reloc     = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));
+      RelocEnd  = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
+      
+      //
+      // Make sure RelocEnd is in the Image range.
+      //
+      if ((CHAR8 *) RelocEnd < (CHAR8 *)((UINTN) ImageContext->ImageAddress) ||
+          (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress + (UINTN)ImageContext->ImageSize)) {
+        ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
         return RETURN_LOAD_ERROR;
       }
-    } else {
-      FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
-                    RelocBase->VirtualAddress +
-                    sizeof(EFI_TE_IMAGE_HEADER) -
-                    Hdr.Te->StrippedSize
-                    );
-    }
-
-    //
-    // Run this relocation record
-    //
-    while (Reloc < RelocEnd) {
-
-      Fixup = FixupBase + (*Reloc & 0xFFF);
-      switch ((*Reloc) >> 12) {
-      case EFI_IMAGE_REL_BASED_ABSOLUTE:
-        break;
-
-      case EFI_IMAGE_REL_BASED_HIGH:
-        Fixup16   = (UINT16 *) Fixup;
-        *Fixup16 = (UINT16) (*Fixup16 + ((UINT16) ((UINT32) Adjust >> 16)));
-        if (FixupData != NULL) {
-          *(UINT16 *) FixupData = *Fixup16;
-          FixupData             = FixupData + sizeof (UINT16);
-        }
-        break;
-
-      case EFI_IMAGE_REL_BASED_LOW:
-        Fixup16   = (UINT16 *) Fixup;
-        *Fixup16  = (UINT16) (*Fixup16 + (UINT16) Adjust);
-        if (FixupData != NULL) {
-          *(UINT16 *) FixupData = *Fixup16;
-          FixupData             = FixupData + sizeof (UINT16);
-        }
-        break;
-
-      case EFI_IMAGE_REL_BASED_HIGHLOW:
-        Fixup32   = (UINT32 *) Fixup;
-        *Fixup32  = *Fixup32 + (UINT32) Adjust;
-        if (FixupData != NULL) {
-          FixupData             = ALIGN_POINTER (FixupData, sizeof (UINT32));
-          *(UINT32 *)FixupData  = *Fixup32;
-          FixupData             = FixupData + sizeof (UINT32);
-        }
-        break;
-
-      case EFI_IMAGE_REL_BASED_DIR64:
-        Fixup64 = (UINT64 *) Fixup;
-        *Fixup64 = *Fixup64 + (UINT64) Adjust;
-        if (FixupData != NULL) {
-          FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64));
-          *(UINT64 *)(FixupData) = *Fixup64;
-          FixupData = FixupData + sizeof(UINT64);
-        }
-        break;
-
-      default:
+
+      if (!(ImageContext->IsTeImage)) {
+        FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
+        if (FixupBase == NULL) {
+          return RETURN_LOAD_ERROR;
+        }
+      } else {
+        FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
+                      RelocBase->VirtualAddress +
+                      sizeof(EFI_TE_IMAGE_HEADER) -
+                      Hdr.Te->StrippedSize
+                      );
+      }    
+
+      //
+      // Run this relocation record
+      //
+      while (Reloc < RelocEnd) {
+
+        Fixup = FixupBase + (*Reloc & 0xFFF);
+        switch ((*Reloc) >> 12) {
+        case EFI_IMAGE_REL_BASED_ABSOLUTE:
+          break;
+
+        case EFI_IMAGE_REL_BASED_HIGH:
+          Fixup16   = (UINT16 *) Fixup;
+          *Fixup16 = (UINT16) (*Fixup16 + ((UINT16) ((UINT32) Adjust >> 16)));
+          if (FixupData != NULL) {
+            *(UINT16 *) FixupData = *Fixup16;
+            FixupData             = FixupData + sizeof (UINT16);
+          }
+          break;
+
+        case EFI_IMAGE_REL_BASED_LOW:
+          Fixup16   = (UINT16 *) Fixup;
+          *Fixup16  = (UINT16) (*Fixup16 + (UINT16) Adjust);
+          if (FixupData != NULL) {
+            *(UINT16 *) FixupData = *Fixup16;
+            FixupData             = FixupData + sizeof (UINT16);
+          }
+          break;
+
+        case EFI_IMAGE_REL_BASED_HIGHLOW:
+          Fixup32   = (UINT32 *) Fixup;
+          *Fixup32  = *Fixup32 + (UINT32) Adjust;
+          if (FixupData != NULL) {
+            FixupData             = ALIGN_POINTER (FixupData, sizeof (UINT32));
+            *(UINT32 *)FixupData  = *Fixup32;
+            FixupData             = FixupData + sizeof (UINT32);
+          }
+          break;
+
+        case EFI_IMAGE_REL_BASED_DIR64:
+          Fixup64 = (UINT64 *) Fixup;
+          *Fixup64 = *Fixup64 + (UINT64) Adjust;
+          if (FixupData != NULL) {
+            FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64));
+            *(UINT64 *)(FixupData) = *Fixup64;
+            FixupData = FixupData + sizeof(UINT64);
+          }
+          break;
+
+        default:
+          //
+          // The common code does not handle some of the stranger IPF relocations
+          // PeCoffLoaderRelocateImageEx () adds support for these complex fixups
+          // on IPF and is a No-Op on other architectures.
+          //
+          Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);
+          if (RETURN_ERROR (Status)) {
+            ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
+            return Status;
+          }
+        }
+
         //
-        // The common code does not handle some of the stranger IPF relocations
-        // PeCoffLoaderRelocateImageEx () adds support for these complex fixups
-        // on IPF and is a No-Op on other architectures.
+        // Next relocation record
         //
-        Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);
-        if (RETURN_ERROR (Status)) {
-          ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
-          return Status;
-        }
+        Reloc += 1;
       }
 
       //
-      // Next relocation record
-      //
-      Reloc += 1;
-    }
-
-    //
-    // Next reloc block
-    //
-    RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;
-  }
-
-  //
-  // Adjust the EntryPoint to match the linked-to address
-  //
-  if (ImageContext->DestinationAddress != 0) {
-     ImageContext->EntryPoint -= (UINT64) ImageContext->ImageAddress;
-     ImageContext->EntryPoint += (UINT64) ImageContext->DestinationAddress;
-     DEBUG((DEBUG_INFO, "%a:%d entry point %x\n", __FILE__, __LINE__, ImageContext->EntryPoint));
+      // Next reloc block
+      //
+      RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;
+    }
+
+    //
+    // Adjust the EntryPoint to match the linked-to address
+    //
+    if (ImageContext->DestinationAddress != 0) {
+       ImageContext->EntryPoint -= (UINT64) ImageContext->ImageAddress;
+       ImageContext->EntryPoint += (UINT64) ImageContext->DestinationAddress;
+    }
   }
 
