[MC] Common symbols weren't being checked for redeclaration which allowed an assembly file to generate an assertion in setCommon(): !isCommon(). This change allows redeclaration as long as the size and alignment match exactly, otherwise report a fatal error.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239227 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Colin LeMahieu
2015-06-06 20:12:40 +00:00
parent 68081f41fa
commit 2ca8f0f5d6
4 changed files with 28 additions and 1 deletions

View File

@@ -258,6 +258,21 @@ public:
return CommonAlign;
}
/// Declare this symbol as being 'common'.
///
/// \param Size - The size of the symbol.
/// \param Align - The alignment of the symbol.
/// \return True if symbol was already declared as a different type
bool declareCommon(uint64_t Size, unsigned Align) {
assert(isCommon() || getOffset() == 0);
if(isCommon()) {
if(CommonSize != Size || CommonAlign != Align)
return true;
} else
setCommon(Size, Align);
return false;
}
/// Is this a 'common' symbol.
bool isCommon() const { return CommonAlign != -1U; }