forked from OSchip/llvm-project
MC, COFF: Align section contents to a four byte boundary
llvm-svn: 228879
This commit is contained in:
parent
e630433754
commit
3df3c61e91
|
@ -939,7 +939,8 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
|
|||
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;
|
||||
}
|
||||
|
@ -1009,9 +1010,15 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
|
|||
continue;
|
||||
|
||||
if ((*i)->Header.PointerToRawData != 0) {
|
||||
assert(OS.tell() == (*i)->Header.PointerToRawData &&
|
||||
assert(OS.tell() <= (*i)->Header.PointerToRawData &&
|
||||
"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);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,14 @@ entry:
|
|||
ret void
|
||||
}
|
||||
|
||||
; CHECK: Section {
|
||||
; CHECK: Name: .text
|
||||
; CHECK: PointerToRawData: 0xB4
|
||||
; CHECK: }
|
||||
|
||||
; CHECK: Section {
|
||||
; CHECK: Name: .drectve
|
||||
; CHECK: PointerToRawData: 0xB8
|
||||
; CHECK: Characteristics [
|
||||
; CHECK: IMAGE_SCN_ALIGN_1BYTES
|
||||
; CHECK: IMAGE_SCN_LNK_INFO
|
||||
|
|
Loading…
Reference in New Issue