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
This commit is contained in:
Rafael Espindola
2010-10-05 23:57:26 +00:00
parent e540a6f94a
commit 3729d0052b
2 changed files with 31 additions and 6 deletions

View File

@@ -529,7 +529,8 @@ void ELFObjectWriterImpl::WriteSymbolTable(MCDataFragment *F,
}
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 @@ static bool ShouldRelocOnSymbol(const MCSymbolData &SD,
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 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
return;
}
bool RelocOnSymbol = ShouldRelocOnSymbol(SD, Target);
bool RelocOnSymbol = ShouldRelocOnSymbol(SD, Target, *Fragment);
if (!RelocOnSymbol) {
Index = F->getParent()->getOrdinal();