From: Daniel Dunbar Date: Mon, 8 Mar 2010 21:10:39 +0000 (+0000) Subject: MC/Mach-O: Error out instead of crashing on invalid scattered relocation expressions. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0ce6bd55c38b2e146b5ce887bae576ee538bb575;p=oota-llvm.git 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 --- diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 96227dbee50..3f40a6d6a4c 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -447,13 +447,22 @@ public: // See . 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(); }