[PECOFF][Writer] Fix wrong section header.

llvm-svn: 185205
This commit is contained in:
Rui Ueyama 2013-06-28 20:10:36 +00:00
parent f269497068
commit e9dd5f98cf
3 changed files with 10 additions and 7 deletions

View File

@ -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:

View File

@ -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

View File

@ -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