diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-04-02 07:02:51 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-04-02 07:02:51 +0000 |
commit | 949eb3f6a7deda71c7280ff6e689ddf79cf737ce (patch) | |
tree | 3765c8a377a7d292e7a9d7d6c826e5acc6c59216 /llvm/lib/MC/MachObjectWriter.cpp | |
parent | 0ee57cede02033cbc28a9b566e8c0ab2aa18dedf (diff) | |
download | bcm5719-llvm-949eb3f6a7deda71c7280ff6e689ddf79cf737ce.tar.gz bcm5719-llvm-949eb3f6a7deda71c7280ff6e689ddf79cf737ce.zip |
Revert r233595, "MC: For variable symbols, maintain MCSymbol::Section as a cache."
llvm-svn: 233898
Diffstat (limited to 'llvm/lib/MC/MachObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/MachObjectWriter.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp index 56cccab1d39..5e9e86f18a0 100644 --- a/llvm/lib/MC/MachObjectWriter.cpp +++ b/llvm/lib/MC/MachObjectWriter.cpp @@ -649,12 +649,33 @@ void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm, } } +void MachObjectWriter::markAbsoluteVariableSymbols(MCAssembler &Asm, + const MCAsmLayout &Layout) { + for (MCSymbolData &SD : Asm.symbols()) { + if (!SD.getSymbol().isVariable()) + continue; + + // Is the variable is a symbol difference (SA - SB + C) expression, + // and neither symbol is external, mark the variable as absolute. + const MCExpr *Expr = SD.getSymbol().getVariableValue(); + MCValue Value; + if (Expr->EvaluateAsRelocatable(Value, &Layout, nullptr)) { + if (Value.getSymA() && Value.getSymB()) + const_cast<MCSymbol*>(&SD.getSymbol())->setAbsolute(); + } + } +} + void MachObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout) { computeSectionAddresses(Asm, Layout); // Create symbol data for any indirect symbols. BindIndirectSymbols(Asm); + + // Mark symbol difference expressions in variables (from .set or = directives) + // as absolute. + markAbsoluteVariableSymbols(Asm, Layout); } bool MachObjectWriter:: |