X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FMC%2FELFObjectWriter.cpp;h=b6e1223bc418a1e6de7df9195c497fe1eeb76670;hb=bf57b838b8548ae581739cdc3dfbf4e23beb45df;hp=10e67d20d5c45a9a0363963ccc999b742261875e;hpb=bff66a86e6e44dc7424cd2d7719ac80630b3a5f8;p=oota-llvm.git diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 10e67d20d5c..b6e1223bc41 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -344,14 +344,6 @@ namespace { MCDataFragment *F, const MCSectionData *SD); - virtual bool - IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm, - const MCSymbolRefExpr *A, - const MCSymbolRefExpr *B) const { - // FIXME: Implement this! - return false; - } - virtual bool IsFixupFullyResolved(const MCAssembler &Asm, const MCValue Target, bool IsPCRel, @@ -526,6 +518,15 @@ static uint64_t SymbolValue(MCSymbolData &Data, const MCAsmLayout &Layout) { return Data.getCommonAlignment(); const MCSymbol &Symbol = Data.getSymbol(); + + if (Symbol.isAbsolute() && Symbol.isVariable()) { + if (const MCExpr *Value = Symbol.getVariableValue()) { + int64_t IntValue; + if (Value->EvaluateAsAbsolute(IntValue, Layout)) + return (uint64_t)IntValue; + } + } + if (!Symbol.isInSection()) return 0; @@ -593,26 +594,15 @@ void ELFObjectWriter::WriteSymbol(MCDataFragment *SymtabF, uint64_t Value = SymbolValue(Data, Layout); uint64_t Size = 0; - const MCExpr *ESize; assert(!(Data.isCommon() && !Data.isExternal())); - ESize = Data.getSize(); - if (Data.getSize()) { - MCValue Res; - if (ESize->getKind() == MCExpr::Binary) { - const MCBinaryExpr *BE = static_cast(ESize); - - if (BE->EvaluateAsRelocatable(Res, &Layout)) { - assert(!Res.getSymA() || !Res.getSymA()->getSymbol().isDefined()); - assert(!Res.getSymB() || !Res.getSymB()->getSymbol().isDefined()); - Size = Res.getConstant(); - } - } else if (ESize->getKind() == MCExpr::Constant) { - Size = static_cast(ESize)->getValue(); - } else { - assert(0 && "Unsupported size expression"); - } + const MCExpr *ESize = Data.getSize(); + if (ESize) { + int64_t Res; + if (!ESize->EvaluateAsAbsolute(Res, Layout)) + report_fatal_error("Size expression must be absolute."); + Size = Res; } // Write out the symbol table entry