summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-04-17 11:27:13 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-04-17 11:27:13 +0000
commit88af411117b2fb52d3140579243bdfaa4a5369d6 (patch)
tree3bfeb7a0056eddae8ae5147f938c8b741ffc976f /llvm/lib
parent3b5f7e99652cffda7417b5d5919fb8b408143a76 (diff)
downloadbcm5719-llvm-88af411117b2fb52d3140579243bdfaa4a5369d6.tar.gz
bcm5719-llvm-88af411117b2fb52d3140579243bdfaa4a5369d6.zip
Add a proper fix for pr23025.
Instead of avoiding looking past every global symbol, only do so if the symbol is in a comdat. llvm-svn: 235181
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/WinCOFFObjectWriter.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index fcd8219abd4..a4b6bf9b08f 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -663,9 +663,21 @@ bool WinCOFFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
}
bool WinCOFFObjectWriter::isWeak(const MCSymbolData &SD) const {
- // FIXME: this is for PR23025. Write a good description on
- // why this is needed.
- return SD.isExternal();
+ if (!SD.isExternal())
+ return false;
+
+ const MCSymbol &Sym = SD.getSymbol();
+ if (!Sym.isInSection())
+ return false;
+
+ const auto &Sec = cast<MCSectionCOFF>(Sym.getSection());
+ if (!Sec.getCOMDATSymbol())
+ return false;
+
+ // It looks like for COFF it is invalid to replace a reference to a global
+ // in a comdat with a reference to a local.
+ // FIXME: Add a specification reference if available.
+ return true;
}
void WinCOFFObjectWriter::RecordRelocation(
@@ -674,7 +686,7 @@ void WinCOFFObjectWriter::RecordRelocation(
assert(Target.getSymA() && "Relocation must reference a symbol!");
const MCSymbol &Symbol = Target.getSymA()->getSymbol();
- const MCSymbol &A = Symbol.AliasedSymbol();
+ const MCSymbol &A = Symbol;
if (!Asm.hasSymbolData(A))
Asm.getContext().FatalError(
Fixup.getLoc(),
OpenPOWER on IntegriCloud