summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-02-11 22:22:30 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-02-11 22:22:30 +0000
commit3df3c61e91974fa3d3dcb053b977d1c7d8daa55c (patch)
tree4b807b29ece01bb838a59e8123fb1a2250fd682d /llvm/lib/MC
parente63043375462dd0f46235fc92813361316c1cfbb (diff)
downloadbcm5719-llvm-3df3c61e91974fa3d3dcb053b977d1c7d8daa55c.tar.gz
bcm5719-llvm-3df3c61e91974fa3d3dcb053b977d1c7d8daa55c.zip
MC, COFF: Align section contents to a four byte boundary
llvm-svn: 228879
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/WinCOFFObjectWriter.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index e3985815e45..ce6dcfda8ff 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -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);
}
OpenPOWER on IntegriCloud