MC/Mach-O: Error out instead of crashing on invalid scattered relocation expressions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97983 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-03-08 21:10:39 +00:00
parent b93c72cda4
commit 0ce6bd55c3

View File

@ -447,13 +447,22 @@ public:
// See <reloc.h>.
const MCSymbol *A = Target.getSymA();
MCSymbolData *SD = SymbolMap.lookup(A);
if (!SD->getFragment())
llvm_report_error("symbol '" + A->getName() +
"' can not be undefined in a subtraction expression");
uint32_t Value = SD->getFragment()->getAddress() + SD->getOffset();
uint32_t Value2 = 0;
if (const MCSymbol *B = Target.getSymB()) {
Type = RIT_LocalDifference;
MCSymbolData *SD = SymbolMap.lookup(B);
if (!SD->getFragment())
llvm_report_error("symbol '" + B->getName() +
"' can not be undefined in a subtraction expression");
Type = RIT_LocalDifference;
Value2 = SD->getFragment()->getAddress() + SD->getOffset();
}