summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-01-27 03:53:26 +0000
committerRui Ueyama <ruiu@google.com>2014-01-27 03:53:26 +0000
commit7d1bf4504730d4494031fe243786b6aba425ef5e (patch)
treea3ac3846eafdc4b07eaa8b25fd32344ae8606abf
parentf1a2d55e2bcb147a10b430b5ed3a9776762d5aeb (diff)
downloadbcm5719-llvm-7d1bf4504730d4494031fe243786b6aba425ef5e.tar.gz
bcm5719-llvm-7d1bf4504730d4494031fe243786b6aba425ef5e.zip
[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. llvm-svn: 200184
-rw-r--r--lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp4
-rw-r--r--lld/test/pecoff/peplus.test2
2 files changed, 3 insertions, 3 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
index 83457ac8597..a0760fbeca0 100644
--- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
+++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
@@ -322,8 +322,8 @@ PEHeaderChunk<PEHeader>::PEHeaderChunk(const PECOFFLinkingContext &ctx)
_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 |
diff --git a/lld/test/pecoff/peplus.test b/lld/test/pecoff/peplus.test
index 0d7bdc00206..b3717ce53ae 100644
--- a/lld/test/pecoff/peplus.test
+++ b/lld/test/pecoff/peplus.test
@@ -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)
OpenPOWER on IntegriCloud