diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-05-12 22:51:35 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-05-12 22:51:35 +0000 |
commit | 7cd309f7dc8e7cb7de6153103df4aff3ab52030f (patch) | |
tree | 020f84172345019c79742f620dad0092557f009b /llvm/lib/MC/MCAssembler.cpp | |
parent | 597eb48168ba18fd4b1ff669e23ed3a647690cef (diff) | |
download | bcm5719-llvm-7cd309f7dc8e7cb7de6153103df4aff3ab52030f.tar.gz bcm5719-llvm-7cd309f7dc8e7cb7de6153103df4aff3ab52030f.zip |
MC: Explicitly check that only virtual fragments appear in virtual sections.
llvm-svn: 103663
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 6cdef20d249..b8b60af8fb7 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/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; } |