[lld] r200278 - [PECOFF] Replace magic numbers with sizeof.
Rui Ueyama
ruiu at google.com
Mon Jan 27 17:55:38 PST 2014
Author: ruiu
Date: Mon Jan 27 19:55:37 2014
New Revision: 200278
URL: http://llvm.org/viewvc/llvm-project?rev=200278&view=rev
Log:
[PECOFF] Replace magic numbers with sizeof.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=200278&r1=200277&r2=200278&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Mon Jan 27 19:55:37 2014
@@ -330,9 +330,6 @@ PEHeaderChunk<PEHeader>::PEHeaderChunk(c
_coffHeader.Machine = ctx.getMachineType();
_coffHeader.TimeDateStamp = time(nullptr);
- // 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 |
llvm::COFF::IMAGE_FILE_EXECUTABLE_IMAGE;
@@ -408,6 +405,10 @@ PEHeaderChunk<PEHeader>::PEHeaderChunk(c
// The number of data directory entries. We always have 16 entries.
_peHeader.NumberOfRvaAndSize = 16;
+
+ // The size of PE header including optional data directory.
+ _coffHeader.SizeOfOptionalHeader = sizeof(PEHeader) +
+ _peHeader.NumberOfRvaAndSize * sizeof(llvm::object::data_directory);
}
template <>
More information about the llvm-commits
mailing list