diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-08 21:10:39 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-08 21:10:39 +0000 |
commit | 0ce6bd55c38b2e146b5ce887bae576ee538bb575 (patch) | |
tree | 02eb06f02e56900f5c676231e31a034cd678ccf7 /lib/MC/MCAssembler.cpp | |
parent | b93c72cda456c96224d25e1df11112bd9b69cf69 (diff) |
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
Diffstat (limited to 'lib/MC/MCAssembler.cpp')
-rw-r--r-- | lib/MC/MCAssembler.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 96227dbee5..3f40a6d6a4 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -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(); } |