From d3da36286f9ffe6951abec67b82837e432c858cf Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 14 Mar 2010 03:10:40 +0000 Subject: [PATCH] MC: Fix a crash on invalid, attempting to evaluate undefined symbols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98464 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCExpr.cpp | 7 ++++--- lib/MC/MCMachOStreamer.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 8d84f53037d..3bd6b1b6950 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -195,10 +195,11 @@ bool MCExpr::EvaluateAsRelocatable(MCValue &Res, if (!Sym.getValue()->EvaluateAsRelocatable(Res, Layout)) return false; - // Absolutize symbol differences when we have a layout object and the - // target requests it. + // Absolutize symbol differences between defined symbols when we have a + // layout object and the target requests it. if (Layout && Res.getSymB() && - Layout->getAssembler().getBackend().hasAbsolutizedSet()) { + Layout->getAssembler().getBackend().hasAbsolutizedSet() && + Res.getSymA()->isDefined() && Res.getSymB()->isDefined()) { MCSymbolData &A = Layout->getAssembler().getSymbolData(*Res.getSymA()); MCSymbolData &B = Layout->getAssembler().getSymbolData(*Res.getSymB()); Res = MCValue::get(+ A.getFragment()->getAddress() + A.getOffset() diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index 2d833ba351f..73b1074531d 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -184,7 +184,7 @@ void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) { // FIXME: Lift context changes into super class. // FIXME: Set associated section. - Symbol->setValue(Value); + Symbol->setValue(AddValueSymbols(Value)); } void MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol, -- 2.34.1