summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCExpr.cpp4
-rw-r--r--llvm/lib/MC/MCSymbol.cpp8
-rw-r--r--llvm/lib/MC/MachObjectWriter.cpp21
-rw-r--r--llvm/lib/Target/X86/X86AsmPrinter.cpp1
4 files changed, 5 insertions, 29 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index 8a64403362c..0702539218c 100644
--- a/llvm/lib/MC/MCExpr.cpp
+++ b/llvm/lib/MC/MCExpr.cpp
@@ -775,6 +775,10 @@ const MCSection *MCExpr::FindAssociatedSection() const {
if (RHS_S == MCSymbol::AbsolutePseudoSection)
return LHS_S;
+ // Not always correct, but probably the best we can do without more context.
+ if (BE->getOpcode() == MCBinaryExpr::Sub)
+ return MCSymbol::AbsolutePseudoSection;
+
// Otherwise, return the first non-null section.
return LHS_S ? LHS_S : RHS_S;
}
diff --git a/llvm/lib/MC/MCSymbol.cpp b/llvm/lib/MC/MCSymbol.cpp
index 24165254e56..6582574ae94 100644
--- a/llvm/lib/MC/MCSymbol.cpp
+++ b/llvm/lib/MC/MCSymbol.cpp
@@ -55,13 +55,7 @@ void MCSymbol::setVariableValue(const MCExpr *Value) {
assert(!IsUsed && "Cannot set a variable that has already been used.");
assert(Value && "Invalid variable value!");
this->Value = Value;
-
- // Variables should always be marked as in the same "section" as the value.
- const MCSection *Section = Value->FindAssociatedSection();
- if (Section)
- setSection(*Section);
- else
- setUndefined();
+ this->Section = nullptr;
}
void MCSymbol::print(raw_ostream &OS) const {
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 5e9e86f18a0..56cccab1d39 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -649,33 +649,12 @@ 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::
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index f6033a7e157..a84f0585aea 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -523,7 +523,6 @@ void X86AsmPrinter::EmitStartOfAsmFile(Module &M) {
// must be registered in .sxdata. Use of any unregistered handlers will
// cause the process to terminate immediately. LLVM does not know how to
// register any SEH handlers, so its object files should be safe.
- S->setAbsolute();
OutStreamer.EmitSymbolAttribute(S, MCSA_Global);
OutStreamer.EmitAssignment(
S, MCConstantExpr::Create(int64_t(1), MMI->getContext()));
OpenPOWER on IntegriCloud