diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-03-26 21:11:00 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-03-26 21:11:00 +0000 |
commit | aeed3cbce0ef45ecf36258c3883e67f0cb5caf6f (patch) | |
tree | d36b5bf5258108f05389bd6f696a37a026dc9ab9 /llvm/lib/MC/MCExpr.cpp | |
parent | a5bcb2ed8a4d3c23558afb917c64bd7cd05549c8 (diff) | |
download | llvm-aeed3cbce0ef45ecf36258c3883e67f0cb5caf6f.zip llvm-aeed3cbce0ef45ecf36258c3883e67f0cb5caf6f.tar.gz llvm-aeed3cbce0ef45ecf36258c3883e67f0cb5caf6f.tar.bz2 |
Fix PR23025.
There is something in link.exe that requires a relocation to use a
global symbol. Not doing so breaks the chrome build on windows.
This patch sets isWeak for that to work. To compensate,
we then need to look past those symbols when not creating relocations.
This patch includes an ELF test that matches GNU as behaviour.
I am still reducing the chrome build issue and will add a test
once that is done.
llvm-svn: 233318
Diffstat (limited to 'llvm/lib/MC/MCExpr.cpp')
-rw-r--r-- | llvm/lib/MC/MCExpr.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp index 7508ef6..8a64403 100644 --- a/llvm/lib/MC/MCExpr.cpp +++ b/llvm/lib/MC/MCExpr.cpp @@ -584,7 +584,15 @@ bool MCExpr::EvaluateAsRelocatable(MCValue &Res, false); } -static bool canExpand(const MCSymbol &Sym, const MCAssembler *Asm) { +bool MCExpr::evaluateAsValue(MCValue &Res, const MCAsmLayout &Layout) const { + MCAssembler *Assembler = &Layout.getAssembler(); + return EvaluateAsRelocatableImpl(Res, Assembler, &Layout, nullptr, nullptr, + true); +} + +static bool canExpand(const MCSymbol &Sym, const MCAssembler *Asm, bool InSet) { + if (InSet) + return true; if (!Asm) return false; const MCSymbolData &SD = Asm->getSymbolData(Sym); @@ -613,10 +621,11 @@ bool MCExpr::EvaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, // Evaluate recursively if this is a variable. if (Sym.isVariable() && SRE->getKind() == MCSymbolRefExpr::VK_None && - canExpand(Sym, Asm)) { + canExpand(Sym, Asm, InSet)) { + bool IsMachO = SRE->hasSubsectionsViaSymbols(); if (Sym.getVariableValue()->EvaluateAsRelocatableImpl( - Res, Asm, Layout, Fixup, Addrs, true)) { - if (!SRE->hasSubsectionsViaSymbols()) + Res, Asm, Layout, Fixup, Addrs, InSet || IsMachO)) { + if (!IsMachO) return true; const MCSymbolRefExpr *A = Res.getSymA(); |