ELF: Move copy relocation handler to one place. NFC.

llvm-svn: 259467
This commit is contained in:
Rui Ueyama 2016-02-02 06:08:08 +00:00
parent 1ac1338ac8
commit 6d3874b995
1 changed files with 13 additions and 6 deletions

View File

@ -293,16 +293,23 @@ void Writer<ELFT>::scanRelocs(
continue;
}
// If a symbol in a DSO is referenced directly instead of through GOT,
// we need to create a copy relocation for the symbol.
if (auto *B = dyn_cast_or_null<SharedSymbol<ELFT>>(Body)) {
if (B->NeedsCopy)
continue;
if (Target->needsCopyRel(Type, *B)) {
B->NeedsCopy = true;
B->setUsedInDynamicReloc();
Out<ELFT>::RelaDyn->addReloc({&C, &RI});
continue;
}
}
bool NeedsGot = false;
bool NeedsPlt = false;
if (Body) {
if (auto *E = dyn_cast<SharedSymbol<ELFT>>(Body)) {
if (E->NeedsCopy)
continue;
if (Target->needsCopyRel(Type, *Body))
E->NeedsCopy = true;
}
NeedsPlt = Target->needsPlt(Type, *Body);
if (NeedsPlt) {
if (Body->isInPlt())