Use a relocation against the symbol if it is a PLT and the symbol is in another
section. Common because of linkonce sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115718 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index d790291..9f9681a 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -529,7 +529,8 @@
}
static bool ShouldRelocOnSymbol(const MCSymbolData &SD,
- const MCValue &Target) {
+ const MCValue &Target,
+ const MCFragment &F) {
const MCSymbol &Symbol = SD.getSymbol();
if (Symbol.isUndefined())
return true;
@@ -543,6 +544,14 @@
if (SD.isExternal())
return true;
+ const llvm::MCSymbolRefExpr& Ref = *Target.getSymA();
+ const MCSectionELF &Sec2 =
+ static_cast<const MCSectionELF&>(F.getParent()->getSection());
+
+ if (Ref.getKind() == MCSymbolRefExpr::VK_PLT &&
+ &Sec2 != &Section)
+ return true;
+
return false;
}
@@ -587,7 +596,7 @@
return;
}
- bool RelocOnSymbol = ShouldRelocOnSymbol(SD, Target);
+ bool RelocOnSymbol = ShouldRelocOnSymbol(SD, Target, *Fragment);
if (!RelocOnSymbol) {
Index = F->getParent()->getOrdinal();