[lld] r185310 - [PECOFF][Writer] Set SizeOfInitializedData file header.
Rui Ueyama
ruiu at google.com
Mon Jul 1 01:06:49 PDT 2013
Author: ruiu
Date: Mon Jul 1 03:06:48 2013
New Revision: 185310
URL: http://llvm.org/viewvc/llvm-project?rev=185310&view=rev
Log:
[PECOFF][Writer] Set SizeOfInitializedData file header.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
lld/trunk/test/pecoff/hello.test
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=185310&r1=185309&r2=185310&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Mon Jul 1 03:06:48 2013
@@ -220,6 +220,14 @@ public:
_peHeader.SizeOfCode = size;
}
+ virtual void setSizeOfInitializedData(uint64_t size) {
+ _peHeader.SizeOfInitializedData = size;
+ }
+
+ virtual void setSizeOfUninitializedData(uint64_t size) {
+ _peHeader.SizeOfUninitializedData = size;
+ }
+
virtual void setNumberOfSections(uint32_t num) {
_coffHeader.NumberOfSections = num;
}
@@ -610,6 +618,7 @@ public:
peHeader->setSizeOfCode(text->size());
peHeader->setBaseOfCode(text->getVirtualAddress());
peHeader->setBaseOfData(rdata->getVirtualAddress());
+ peHeader->setSizeOfInitializedData(rdata->size() + data->size());
peHeader->setNumberOfSections(numSections);
peHeader->setSizeOfImage(imageSize);
}
Modified: lld/trunk/test/pecoff/hello.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/hello.test?rev=185310&r1=185309&r2=185310&view=diff
==============================================================================
--- lld/trunk/test/pecoff/hello.test (original)
+++ lld/trunk/test/pecoff/hello.test Mon Jul 1 03:06:48 2013
@@ -1,43 +1,51 @@
# RUN: lld -flavor link -out %t1 -subsystem console -force \
# RUN: -- %p/Inputs/hello.obj \
-# RUN: && llvm-readobj -sections %t1 | FileCheck %s
+# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=FILE %s
-CHECK: Format: COFF-i386
-CHECK: Arch: i386
-CHECK: AddressSize: 32bit
-CHECK: Sections [
-CHECK: Section {
-CHECK: Number: 1
-CHECK: Name: .text (2E 74 65 78 74 00 00 00)
-CHECK: VirtualSize: 0x1C
-CHECK: VirtualAddress: 0x1000
-CHECK: RawDataSize: 512
-CHECK: PointerToRawData: 0x200
-CHECK: PointerToRelocations: 0x0
-CHECK: PointerToLineNumbers: 0x0
-CHECK: RelocationCount: 0
-CHECK: LineNumberCount: 0
-CHECK: Characteristics [ (0x60000020)
-CHECK: IMAGE_SCN_CNT_CODE (0x20)
-CHECK: IMAGE_SCN_MEM_EXECUTE (0x20000000)
-CHECK: IMAGE_SCN_MEM_READ (0x40000000)
-CHECK: ]
-CHECK: }
-CHECK: Section {
-CHECK: Number: 2
-CHECK: Name: .data (2E 64 61 74 61 00 00 00)
-CHECK: VirtualSize: 0x18
-CHECK: VirtualAddress: 0x2000
-CHECK: RawDataSize: 512
-CHECK: PointerToRawData: 0x400
-CHECK: PointerToRelocations: 0x0
-CHECK: PointerToLineNumbers: 0x0
-CHECK: RelocationCount: 0
-CHECK: LineNumberCount: 0
-CHECK: Characteristics [ (0xC0000040)
-CHECK: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
-CHECK: IMAGE_SCN_MEM_READ (0x40000000)
-CHECK: IMAGE_SCN_MEM_WRITE (0x80000000)
-CHECK: ]
-CHECK: }
-CHECK: ]
+FILE: ImageOptionalHeader {
+FILE: SizeOfInitializedData: 512
+FILE: }
+
+# RUN: lld -flavor link -out %t1 -subsystem console -force \
+# RUN: -- %p/Inputs/hello.obj \
+# RUN: && llvm-readobj -sections %t1 | FileCheck -check-prefix=SECTIONS %s
+
+SECTIONS: Format: COFF-i386
+SECTIONS: Arch: i386
+SECTIONS: AddressSize: 32bit
+SECTIONS: Sections [
+SECTIONS: Section {
+SECTIONS: Number: 1
+SECTIONS: Name: .text (2E 74 65 78 74 00 00 00)
+SECTIONS: VirtualSize: 0x1C
+SECTIONS: VirtualAddress: 0x1000
+SECTIONS: RawDataSize: 512
+SECTIONS: PointerToRawData: 0x200
+SECTIONS: PointerToRelocations: 0x0
+SECTIONS: PointerToLineNumbers: 0x0
+SECTIONS: RelocationCount: 0
+SECTIONS: LineNumberCount: 0
+SECTIONS: Characteristics [ (0x60000020)
+SECTIONS: IMAGE_SCN_CNT_CODE (0x20)
+SECTIONS: IMAGE_SCN_MEM_EXECUTE (0x20000000)
+SECTIONS: IMAGE_SCN_MEM_READ (0x40000000)
+SECTIONS: ]
+SECTIONS: }
+SECTIONS: Section {
+SECTIONS: Number: 2
+SECTIONS: Name: .data (2E 64 61 74 61 00 00 00)
+SECTIONS: VirtualSize: 0x18
+SECTIONS: VirtualAddress: 0x2000
+SECTIONS: RawDataSize: 512
+SECTIONS: PointerToRawData: 0x400
+SECTIONS: PointerToRelocations: 0x0
+SECTIONS: PointerToLineNumbers: 0x0
+SECTIONS: RelocationCount: 0
+SECTIONS: LineNumberCount: 0
+SECTIONS: Characteristics [ (0xC0000040)
+SECTIONS: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
+SECTIONS: IMAGE_SCN_MEM_READ (0x40000000)
+SECTIONS: IMAGE_SCN_MEM_WRITE (0x80000000)
+SECTIONS: ]
+SECTIONS: }
+SECTIONS: ]
More information about the llvm-commits
mailing list