summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-07-21 16:56:35 +0000
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-07-21 16:56:35 +0000
commit58e4d800962d8b84ad122eceae8df2f6616f34fd (patch)
treebf7060f70cc7d5f481da27d2e18a31c319aa4ed0
parent19bf20e11acd88a02922201f97e6d64edcd16390 (diff)
downloadedk2-58e4d800962d8b84ad122eceae8df2f6616f34fd.zip
edk2-58e4d800962d8b84ad122eceae8df2f6616f34fd.tar.gz
edk2-58e4d800962d8b84ad122eceae8df2f6616f34fd.tar.bz2
Hot fixing for the bug that GenFw can not convert ELF to PE format correctly, the root cause is invalid size of OptionalHeader is computed.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8976 6f19259b-4bc3-4df7-8a09-765794883524
-rwxr-xr-xBaseTools/Bin/Win32/BootSectImage.exebin393216 -> 393216 bytes
-rwxr-xr-xBaseTools/Bin/Win32/EfiLdrImage.exebin421888 -> 421888 bytes
-rwxr-xr-xBaseTools/Bin/Win32/EfiRom.exebin446464 -> 446464 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenBootSector.exebin425984 -> 425984 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenCrc32.exebin425984 -> 425984 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenFfs.exebin430080 -> 430080 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenFv.exebin479232 -> 479232 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenFw.exebin466944 -> 466944 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenPage.exebin421888 -> 421888 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenSec.exebin446464 -> 446464 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenVtf.exebin442368 -> 442368 bytes
-rw-r--r--BaseTools/Bin/Win32/LzmaCompress.exebin397312 -> 397312 bytes
-rwxr-xr-xBaseTools/Bin/Win32/Split.exebin425984 -> 425984 bytes
-rwxr-xr-xBaseTools/Bin/Win32/TianoCompress.exebin434176 -> 434176 bytes
-rwxr-xr-xBaseTools/Bin/Win32/VfrCompile.exebin1146880 -> 1146880 bytes
-rwxr-xr-xBaseTools/Bin/Win32/VolInfo.exebin471040 -> 471040 bytes
-rw-r--r--BaseTools/Source/C/GenFw/GenFw.c32
17 files changed, 25 insertions, 7 deletions
diff --git a/BaseTools/Bin/Win32/BootSectImage.exe b/BaseTools/Bin/Win32/BootSectImage.exe
index a0cf0fd..966832d 100755
--- a/BaseTools/Bin/Win32/BootSectImage.exe
+++ b/BaseTools/Bin/Win32/BootSectImage.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/EfiLdrImage.exe b/BaseTools/Bin/Win32/EfiLdrImage.exe
index 57662bf..89c655d 100755
--- a/BaseTools/Bin/Win32/EfiLdrImage.exe
+++ b/BaseTools/Bin/Win32/EfiLdrImage.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/EfiRom.exe b/BaseTools/Bin/Win32/EfiRom.exe
index 9ca2fb2..643162e 100755
--- a/BaseTools/Bin/Win32/EfiRom.exe
+++ b/BaseTools/Bin/Win32/EfiRom.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenBootSector.exe b/BaseTools/Bin/Win32/GenBootSector.exe
index 08180b4..48a17af 100755
--- a/BaseTools/Bin/Win32/GenBootSector.exe
+++ b/BaseTools/Bin/Win32/GenBootSector.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenCrc32.exe b/BaseTools/Bin/Win32/GenCrc32.exe
index 1b9020e..01234af 100755
--- a/BaseTools/Bin/Win32/GenCrc32.exe
+++ b/BaseTools/Bin/Win32/GenCrc32.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenFfs.exe b/BaseTools/Bin/Win32/GenFfs.exe
index 3ffc0fa..3ee7925 100755
--- a/BaseTools/Bin/Win32/GenFfs.exe
+++ b/BaseTools/Bin/Win32/GenFfs.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenFv.exe b/BaseTools/Bin/Win32/GenFv.exe
index a01bf7e..6011dd3 100755
--- a/BaseTools/Bin/Win32/GenFv.exe
+++ b/BaseTools/Bin/Win32/GenFv.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenFw.exe b/BaseTools/Bin/Win32/GenFw.exe
index 0b6333a..f2b04ed 100755
--- a/BaseTools/Bin/Win32/GenFw.exe
+++ b/BaseTools/Bin/Win32/GenFw.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenPage.exe b/BaseTools/Bin/Win32/GenPage.exe
index 9a1a566..41ac434 100755
--- a/BaseTools/Bin/Win32/GenPage.exe
+++ b/BaseTools/Bin/Win32/GenPage.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenSec.exe b/BaseTools/Bin/Win32/GenSec.exe
index aafcdcc..0c828b8 100755
--- a/BaseTools/Bin/Win32/GenSec.exe
+++ b/BaseTools/Bin/Win32/GenSec.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenVtf.exe b/BaseTools/Bin/Win32/GenVtf.exe
index 26e904a..32eb2c1 100755
--- a/BaseTools/Bin/Win32/GenVtf.exe
+++ b/BaseTools/Bin/Win32/GenVtf.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/LzmaCompress.exe b/BaseTools/Bin/Win32/LzmaCompress.exe
index ce231f8..8ca0bbc 100644
--- a/BaseTools/Bin/Win32/LzmaCompress.exe
+++ b/BaseTools/Bin/Win32/LzmaCompress.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/Split.exe b/BaseTools/Bin/Win32/Split.exe
index 222eccf..4b01eba 100755
--- a/BaseTools/Bin/Win32/Split.exe
+++ b/BaseTools/Bin/Win32/Split.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/TianoCompress.exe b/BaseTools/Bin/Win32/TianoCompress.exe
index 04114bd..b95b67f7 100755
--- a/BaseTools/Bin/Win32/TianoCompress.exe
+++ b/BaseTools/Bin/Win32/TianoCompress.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/VfrCompile.exe b/BaseTools/Bin/Win32/VfrCompile.exe
index 3233415..e9b9977 100755
--- a/BaseTools/Bin/Win32/VfrCompile.exe
+++ b/BaseTools/Bin/Win32/VfrCompile.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/VolInfo.exe b/BaseTools/Bin/Win32/VolInfo.exe
index 6e50174..ebbe398 100755
--- a/BaseTools/Bin/Win32/VolInfo.exe
+++ b/BaseTools/Bin/Win32/VolInfo.exe
Binary files differ
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index 2278948..d570f63 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -583,7 +583,21 @@ ScanSections(
//
CoffOffset = sizeof(EFI_IMAGE_DOS_HEADER) + 0x40;
NtHdrOffset = CoffOffset;
- CoffOffset += sizeof(EFI_IMAGE_OPTIONAL_HEADER_UNION);
+ switch (Ehdr->e_machine) {
+ case EM_386:
+ case EM_ARM:
+ CoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);
+ break;
+ case EM_X86_64:
+ case EM_IA_64:
+ CoffOffset += sizeof (EFI_IMAGE_NT_HEADERS64);
+ break;
+ default:
+ VerboseMsg ("%s unknown e_machine type. Assume IA-32", (UINTN)Ehdr->e_machine);
+ CoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);
+ break;
+ }
+
TableOffset = CoffOffset;
CoffOffset += CoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER);
@@ -1144,6 +1158,7 @@ ConvertElf (
//
// Compute sections new address.
//
+
ScanSections();
VerboseMsg ("Compute sections new address.");
@@ -2660,9 +2675,12 @@ Returns:
//
// Init variable.
//
- DebugDirectoryEntryRva = 0;
- ExportDirectoryEntryRva = 0;
- ResourceDirectoryEntryRva = 0;
+ DebugDirectoryEntryRva = 0;
+ ExportDirectoryEntryRva = 0;
+ ResourceDirectoryEntryRva = 0;
+ DebugDirectoryEntryFileOffset = 0;
+ ExportDirectoryEntryFileOffset = 0;
+ ResourceDirectoryEntryFileOffset = 0;
DosHdr = (EFI_IMAGE_DOS_HEADER *) FileBuffer;
FileHdr = (EFI_IMAGE_FILE_HEADER *) (FileBuffer + DosHdr->e_lfanew + sizeof (UINT32));
@@ -2745,17 +2763,17 @@ Returns:
//
FileHdr->TimeDateStamp = 0;
- if (ExportDirectoryEntryRva != 0) {
+ if (ExportDirectoryEntryFileOffset != 0) {
NewTimeStamp = (UINT32 *) (FileBuffer + ExportDirectoryEntryFileOffset + sizeof (UINT32));
*NewTimeStamp = 0;
}
- if (ResourceDirectoryEntryRva != 0) {
+ if (ResourceDirectoryEntryFileOffset != 0) {
NewTimeStamp = (UINT32 *) (FileBuffer + ResourceDirectoryEntryFileOffset + sizeof (UINT32));
*NewTimeStamp = 0;
}
- if (DebugDirectoryEntryRva != 0) {
+ if (DebugDirectoryEntryFileOffset != 0) {
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) (FileBuffer + DebugDirectoryEntryFileOffset);
DebugEntry->TimeDateStamp = 0;
if (ZeroDebugFlag) {