diff options
author | Rui Ueyama <ruiu@google.com> | 2013-06-28 20:10:36 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2013-06-28 20:10:36 +0000 |
commit | e9dd5f98cf80ed2e6edc213da3226283e7ba7ad5 (patch) | |
tree | 26b3fb51e265ecb83f9003362adfccf6aeb08eb0 /lld | |
parent | f2694970680c9fce4b5876df39964f4d1f2d324f (diff) | |
download | bcm5719-llvm-e9dd5f98cf80ed2e6edc213da3226283e7ba7ad5.tar.gz bcm5719-llvm-e9dd5f98cf80ed2e6edc213da3226283e7ba7ad5.zip |
[PECOFF][Writer] Fix wrong section header.
llvm-svn: 185205
Diffstat (limited to 'lld')
-rw-r--r-- | lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp | 11 | ||||
-rw-r--r-- | lld/test/pecoff/hello.test | 4 | ||||
-rw-r--r-- | lld/test/pecoff/trivial.test | 2 |
3 files changed, 10 insertions, 7 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp index 94c9078a689..be5f5bb1377 100644 --- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp @@ -274,9 +274,10 @@ private: /// written to the raw data section. class SectionChunk : public Chunk { public: + /// Returns the size of the section on disk. The returned value is multiple + /// of disk sector, so the size may include the null padding at the end of + /// section. virtual uint64_t size() const { - // Round up to the nearest alignment border, so that the text segment ends - // at a border. return llvm::RoundUpToAlignment(_size, _align); } @@ -379,9 +380,11 @@ protected: } // Now that we have a list of atoms that to be written in this section, - // and we know the size of the section. + // and we know the size of the section. Let's write them to the section + // header. VirtualSize should be the size of the actual content, and + // SizeOfRawData should be aligned to the section alignment. _sectionHeader.VirtualSize = _size; - _sectionHeader.SizeOfRawData = _size; + _sectionHeader.SizeOfRawData = size(); } private: diff --git a/lld/test/pecoff/hello.test b/lld/test/pecoff/hello.test index 9359e8e2b23..0676950c366 100644 --- a/lld/test/pecoff/hello.test +++ b/lld/test/pecoff/hello.test @@ -11,7 +11,7 @@ CHECK: Number: 1 CHECK: Name: .text (2E 74 65 78 74 00 00 00) CHECK: VirtualSize: 0x1C CHECK: VirtualAddress: 0x1000 -CHECK: RawDataSize: 28 +CHECK: RawDataSize: 512 CHECK: PointerToRawData: 0x200 CHECK: PointerToRelocations: 0x0 CHECK: PointerToLineNumbers: 0x0 @@ -44,7 +44,7 @@ CHECK: Number: 3 CHECK: Name: .data (2E 64 61 74 61 00 00 00) CHECK: VirtualSize: 0x18 CHECK: VirtualAddress: 0x2000 -CHECK: RawDataSize: 24 +CHECK: RawDataSize: 512 CHECK: PointerToRawData: 0x400 CHECK: PointerToRelocations: 0x0 CHECK: PointerToLineNumbers: 0x0 diff --git a/lld/test/pecoff/trivial.test b/lld/test/pecoff/trivial.test index 298129ccf70..a47dab0340f 100644 --- a/lld/test/pecoff/trivial.test +++ b/lld/test/pecoff/trivial.test @@ -66,7 +66,7 @@ SECTIONS: Number: 1 SECTIONS: Name: .text (2E 74 65 78 74 00 00 00) SECTIONS: VirtualSize: 0x6 SECTIONS: VirtualAddress: 0x1000 -SECTIONS: RawDataSize: 6 +SECTIONS: RawDataSize: 512 SECTIONS: PointerToRawData: 0x200 SECTIONS: PointerToRelocations: 0x0 SECTIONS: PointerToLineNumbers: 0x0 |