[lld] r200184 - [PECOFF] Fix PE/COFF optional header size for PE32+.
Rui Ueyama
ruiu at google.com
Sun Jan 26 19:53:26 PST 2014
Author: ruiu
Date: Sun Jan 26 21:53:26 2014
New Revision: 200184
URL: http://llvm.org/viewvc/llvm-project?rev=200184&view=rev
Log:
[PECOFF] Fix PE/COFF optional header size for PE32+.
The optional header for PE32+ is a bit larger than PE32 because some of
its fields are extended to 8 bytes.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
lld/trunk/test/pecoff/peplus.test
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=200184&r1=200183&r2=200184&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Sun Jan 26 21:53:26 2014
@@ -322,8 +322,8 @@ PEHeaderChunk<PEHeader>::PEHeaderChunk(c
_coffHeader.Machine = ctx.getMachineType();
_coffHeader.TimeDateStamp = time(nullptr);
- // The size of PE header including optional data directory is always 224.
- _coffHeader.SizeOfOptionalHeader = 224;
+ // The size of PE header including optional data directory.
+ _coffHeader.SizeOfOptionalHeader = ctx.is64Bit() ? 240 : 224;
// Attributes of the executable.
uint16_t characteristics = llvm::COFF::IMAGE_FILE_32BIT_MACHINE |
Modified: lld/trunk/test/pecoff/peplus.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/peplus.test?rev=200184&r1=200183&r2=200184&view=diff
==============================================================================
--- lld/trunk/test/pecoff/peplus.test (original)
+++ lld/trunk/test/pecoff/peplus.test Sun Jan 26 21:53:26 2014
@@ -11,7 +11,7 @@ CHECK-NEXT: SectionCount: 3
CHECK-NEXT: TimeDateStamp:
CHECK-NEXT: PointerToSymbolTable: 0x0
CHECK-NEXT: SymbolCount: 0
-CHECK-NEXT: OptionalHeaderSize: 224
+CHECK-NEXT: OptionalHeaderSize: 240
CHECK-NEXT: Characteristics [ (0x102)
CHECK-NEXT: IMAGE_FILE_32BIT_MACHINE (0x100)
CHECK-NEXT: IMAGE_FILE_EXECUTABLE_IMAGE (0x2)
More information about the llvm-commits
mailing list