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
This commit is contained in:
Daniel Dunbar 2010-03-14 03:10:40 +00:00
parent 7561d48095
commit d3da36286f
2 changed files with 5 additions and 4 deletions

View File

@ -195,10 +195,11 @@ bool MCExpr::EvaluateAsRelocatable(MCValue &Res,
if (!Sym.getValue()->EvaluateAsRelocatable(Res, Layout)) if (!Sym.getValue()->EvaluateAsRelocatable(Res, Layout))
return false; return false;
// Absolutize symbol differences when we have a layout object and the // Absolutize symbol differences between defined symbols when we have a
// target requests it. // layout object and the target requests it.
if (Layout && Res.getSymB() && 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 &A = Layout->getAssembler().getSymbolData(*Res.getSymA());
MCSymbolData &B = Layout->getAssembler().getSymbolData(*Res.getSymB()); MCSymbolData &B = Layout->getAssembler().getSymbolData(*Res.getSymB());
Res = MCValue::get(+ A.getFragment()->getAddress() + A.getOffset() Res = MCValue::get(+ A.getFragment()->getAddress() + A.getOffset()

View File

@ -184,7 +184,7 @@ void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
// FIXME: Lift context changes into super class. // FIXME: Lift context changes into super class.
// FIXME: Set associated section. // FIXME: Set associated section.
Symbol->setValue(Value); Symbol->setValue(AddValueSymbols(Value));
} }
void MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol, void MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol,