diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-12-22 19:05:49 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-12-22 19:05:49 +0000 |
commit | bf57b838b8548ae581739cdc3dfbf4e23beb45df (patch) | |
tree | d17f7f8bac6f5fb13f3f2afd1ae2ed63f5040d7e /lib/MC/MCExpr.cpp | |
parent | 33a03c73ef8f0bd0351754048669b6337539e731 (diff) |
Revert r122359 while I debug PR8845.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122427 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCExpr.cpp')
-rw-r--r-- | lib/MC/MCExpr.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 58f2e94dd6..8fdf837833 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -269,13 +269,27 @@ bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm, // FIXME: The use if InSet = Addrs is a hack. Setting InSet causes us // absolutize differences across sections and that is what the MachO writer // uses Addrs for. - bool IsRelocatable = - EvaluateAsRelocatableImpl(Value, Asm, Layout, Addrs, /*InSet*/ Addrs); + if (!EvaluateAsRelocatableImpl(Value, Asm, Layout, Addrs, /*InSet*/ Addrs) || + !Value.isAbsolute()) { + // EvaluateAsAbsolute is defined to return the "current value" of + // the expression if we are given a Layout object, even in cases + // when the value is not fixed. + if (Layout) { + Res = Value.getConstant(); + if (Value.getSymA()) { + Res += Layout->getSymbolOffset( + &Layout->getAssembler().getSymbolData(Value.getSymA()->getSymbol())); + } + if (Value.getSymB()) { + Res -= Layout->getSymbolOffset( + &Layout->getAssembler().getSymbolData(Value.getSymB()->getSymbol())); + } + } + return false; + } - // Record the current value. Res = Value.getConstant(); - - return IsRelocatable && Value.isAbsolute(); + return true; } /// \brief Helper method for \see EvaluateSymbolAdd(). |