diff options
Diffstat (limited to 'llvm/lib/MC/MCSymbol.cpp')
-rw-r--r-- | llvm/lib/MC/MCSymbol.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCSymbol.cpp b/llvm/lib/MC/MCSymbol.cpp index 6582574ae94..24165254e56 100644 --- a/llvm/lib/MC/MCSymbol.cpp +++ b/llvm/lib/MC/MCSymbol.cpp @@ -55,7 +55,13 @@ 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; - this->Section = nullptr; + + // Variables should always be marked as in the same "section" as the value. + const MCSection *Section = Value->FindAssociatedSection(); + if (Section) + setSection(*Section); + else + setUndefined(); } void MCSymbol::print(raw_ostream &OS) const { |