[lld] r185534 - [PECOFF][Writer] Fix SizeOfImage header. It should include the first unmapped page.

Rui Ueyama ruiu at google.com
Wed Jul 3 05:55:56 PDT 2013


Author: ruiu
Date: Wed Jul  3 07:55:56 2013
New Revision: 185534

URL: http://llvm.org/viewvc/llvm-project?rev=185534&view=rev
Log:
[PECOFF][Writer] Fix SizeOfImage header. It should include the first unmapped page.

Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
    lld/trunk/test/pecoff/trivial.test

Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=185534&r1=185533&r2=185534&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Wed Jul  3 07:55:56 2013
@@ -566,20 +566,18 @@ private:
     // there's no technical reason to do so, but we'll follow that convention
     // so that we don't produce odd-looking binary. We should update the code
     // (or this comment) once we figure the reason out.
-    uint32_t offset = PAGE_SIZE;
-    uint32_t va = offset;
+    uint32_t rva = PAGE_SIZE;
     for (auto &cp : _chunks) {
       if (SectionChunk *chunk = dyn_cast<SectionChunk>(&*cp)) {
-        chunk->setVirtualAddress(va);
-
+        chunk->setVirtualAddress(rva);
         // Skip the empty section.
         if (chunk->size() == 0)
           continue;
         numSections++;
-        va = llvm::RoundUpToAlignment(va + chunk->size(), PAGE_SIZE);
+        rva = llvm::RoundUpToAlignment(rva + chunk->size(), PAGE_SIZE);
       }
     }
-    imageSize = va - offset;
+    imageSize = rva;
   }
 
   /// Apply relocations to the output file buffer. This two pass. In the first

Modified: lld/trunk/test/pecoff/trivial.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/trivial.test?rev=185534&r1=185533&r2=185534&view=diff
==============================================================================
--- lld/trunk/test/pecoff/trivial.test (original)
+++ lld/trunk/test/pecoff/trivial.test Wed Jul  3 07:55:56 2013
@@ -39,7 +39,7 @@ FILE:   MajorImageVersion: 0
 FILE:   MinorImageVersion: 0
 FILE:   MajorSubsystemVersion: 3
 FILE:   MinorSubsystemVersion: 11
-FILE:   SizeOfImage: 4096
+FILE:   SizeOfImage: 8192
 FILE:   SizeOfHeaders: 512
 FILE:   Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
 FILE:   Subsystem [ (0x8540)





More information about the llvm-commits mailing list