git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228879
91177308-0d34-0410-b5e6-
96231b3b80d8
Sec->Header.SizeOfRawData = Layout.getSectionAddressSize(&Section);
if (IsPhysicalSection(Sec)) {
Sec->Header.SizeOfRawData = Layout.getSectionAddressSize(&Section);
if (IsPhysicalSection(Sec)) {
- Sec->Header.PointerToRawData = offset;
+ // Align the section data to a four byte boundary.
+ Sec->Header.PointerToRawData = RoundUpToAlignment(offset, 4);
offset += Sec->Header.SizeOfRawData;
}
offset += Sec->Header.SizeOfRawData;
}
continue;
if ((*i)->Header.PointerToRawData != 0) {
continue;
if ((*i)->Header.PointerToRawData != 0) {
- assert(OS.tell() == (*i)->Header.PointerToRawData &&
+ assert(OS.tell() <= (*i)->Header.PointerToRawData &&
"Section::PointerToRawData is insane!");
"Section::PointerToRawData is insane!");
+ unsigned SectionDataPadding = (*i)->Header.PointerToRawData - OS.tell();
+ assert(SectionDataPadding < 4 &&
+ "Should only need at most three bytes of padding!");
+
+ WriteZeros(SectionDataPadding);
+
Asm.writeSectionData(j, Layout);
}
Asm.writeSectionData(j, Layout);
}
+; CHECK: Section {
+; CHECK: Name: .text
+; CHECK: PointerToRawData: 0xB4
+; CHECK: }
+
; CHECK: Section {
; CHECK: Name: .drectve
; CHECK: Section {
; CHECK: Name: .drectve
+; CHECK: PointerToRawData: 0xB8
; CHECK: Characteristics [
; CHECK: IMAGE_SCN_ALIGN_1BYTES
; CHECK: IMAGE_SCN_LNK_INFO
; CHECK: Characteristics [
; CHECK: IMAGE_SCN_ALIGN_1BYTES
; CHECK: IMAGE_SCN_LNK_INFO