summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BasePeCoffLib
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2009-10-15 17:21:22 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2009-10-15 17:21:22 +0000
commit2816e216c29a882dc5c6b4ae3ccd0b844b3688dc (patch)
treef5a5055790923adad6010318eaabcdd259ecd938 /MdePkg/Library/BasePeCoffLib
parentce422d36a889710183a38cb69408f36d175d8c0c (diff)
downloadedk2-platforms-2816e216c29a882dc5c6b4ae3ccd0b844b3688dc.tar.xz
Do not update the ImageBase in the PE/COFF header if Adjust is 0.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9341 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BasePeCoffLib')
-rw-r--r--MdePkg/Library/BasePeCoffLib/BasePeCoff.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index 586b81eadb..240ea1309b 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -572,7 +572,9 @@ PeCoffLoaderRelocateImage (
// Use PE32 offset
//
Adjust = (UINT64)BaseAddress - Hdr.Pe32->OptionalHeader.ImageBase;
- Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress;
+ if (Adjust != 0) {
+ Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress;
+ }
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
RelocDir = &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
@@ -581,7 +583,9 @@ PeCoffLoaderRelocateImage (
// Use PE32+ offset
//
Adjust = (UINT64) BaseAddress - Hdr.Pe32Plus->OptionalHeader.ImageBase;
- Hdr.Pe32Plus->OptionalHeader.ImageBase = (UINT64)BaseAddress;
+ if (Adjust != 0) {
+ Hdr.Pe32Plus->OptionalHeader.ImageBase = (UINT64)BaseAddress;
+ }
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
RelocDir = &Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
@@ -612,7 +616,9 @@ PeCoffLoaderRelocateImage (
} else {
Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);
Adjust = (UINT64) (BaseAddress - Hdr.Te->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->ImageBase);
- Hdr.Te->ImageBase = (UINT64) (BaseAddress - Hdr.Te->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER));
+ if (Adjust != 0) {
+ Hdr.Te->ImageBase = (UINT64) (BaseAddress - Hdr.Te->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER));
+ }
//
// Find the relocation block