summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-05-12 22:51:35 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-05-12 22:51:35 +0000
commite2fee5b2369b4d6c31d3ad3b0a7d257e6df22041 (patch)
tree04f8ba716145078135037946edfadf4ca3d54412 /lib
parent3153fec733acd079a9e681d16d39253b9517e02c (diff)
downloadllvm-e2fee5b2369b4d6c31d3ad3b0a7d257e6df22041.tar.gz
llvm-e2fee5b2369b4d6c31d3ad3b0a7d257e6df22041.tar.bz2
llvm-e2fee5b2369b4d6c31d3ad3b0a7d257e6df22041.tar.xz
MC: Explicitly check that only virtual fragments appear in virtual sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103663 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/MCAssembler.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 6cdef20d24..b8b60af8fb 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -534,6 +534,9 @@ static void WriteFragmentData(const MCAssembler &Asm, const MCAsmLayout &Layout,
case MCFragment::FT_Fill: {
MCFillFragment &FF = cast<MCFillFragment>(F);
+
+ assert(FF.getValueSize() && "Invalid virtual align in concrete fragment!");
+
for (uint64_t i = 0, e = FF.getSize() / FF.getValueSize(); i != e; ++i) {
switch (FF.getValueSize()) {
default:
@@ -578,6 +581,26 @@ void MCAssembler::WriteSectionData(const MCSectionData *SD,
// Ignore virtual sections.
if (getBackend().isVirtualSection(SD->getSection())) {
assert(SectionFileSize == 0 && "Invalid size for section!");
+
+ // Check that contents are only things legal inside a virtual section.
+ for (MCSectionData::const_iterator it = SD->begin(),
+ ie = SD->end(); it != ie; ++it) {
+ switch (it->getKind()) {
+ default:
+ assert(0 && "Invalid fragment in virtual section!");
+ case MCFragment::FT_Align:
+ assert(!cast<MCAlignFragment>(it)->getValueSize() &&
+ "Invalid align in virtual section!");
+ break;
+ case MCFragment::FT_Fill:
+ assert(!cast<MCFillFragment>(it)->getValueSize() &&
+ "Invalid fill in virtual section!");
+ break;
+ case MCFragment::FT_ZeroFill:
+ break;
+ }
+ }
+
return;
}