[lld] r183876 - [PECOFF] Define constants for page size and disk sector size.
Rui Ueyama
ruiu at google.com
Wed Jun 12 16:45:32 PDT 2013
Author: ruiu
Date: Wed Jun 12 18:45:32 2013
New Revision: 183876
URL: http://llvm.org/viewvc/llvm-project?rev=183876&view=rev
Log:
[PECOFF] Define constants for page size and disk sector size.
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=183876&r1=183875&r2=183876&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Wed Jun 12 18:45:32 2013
@@ -16,7 +16,7 @@
/// executable file. Currently it can only output ".text" section; other
/// sections including the symbol table are silently ignored.
///
-/// This writer currently supports 32 bit PE/COFF only.
+/// This writer currently supports 32 bit PE/COFF for x86 processor only.
///
//===----------------------------------------------------------------------===//
@@ -44,6 +44,14 @@ namespace pecoff {
namespace {
+// Page size of x86 processor. Some data needs to be aligned at page boundary
+// when loaded into memory.
+const int PAGE_SIZE = 4096;
+
+// Disk sector size. Some data needs to be aligned at disk sector boundary in
+// file.
+const int SECTOR_SIZE = 512;
+
/// A Chunk is an abstrace contiguous range in an output file.
class Chunk {
public:
@@ -131,10 +139,10 @@ public:
// Sections should be page-aligned when loaded into memory, which is 4KB on
// x86.
- _peHeader.SectionAlignment = 4096;
+ _peHeader.SectionAlignment = PAGE_SIZE;
// Sections in an executable file on disk should be sector-aligned (512 byte).
- _peHeader.FileAlignment = 512;
+ _peHeader.FileAlignment = SECTOR_SIZE;
// The required Windows version number. This is the internal version and
// shouldn't be confused with product name. Windows 7 is version 6.1 and
@@ -289,7 +297,7 @@ public:
TextSectionChunk(const File &linkedFile)
: SectionChunk(createSectionHeader()) {
// The text section should be aligned to disk sector.
- _align = 512;
+ _align = SECTOR_SIZE;
// Extract executable atoms from the linked file and append them to this
// section.
More information about the llvm-commits
mailing list