[lld] r259470 - ELF: Move PLT relocation handler to one place. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 1 23:07:34 PST 2016
Author: ruiu
Date: Tue Feb 2 01:07:34 2016
New Revision: 259470
URL: http://llvm.org/viewvc/llvm-project?rev=259470&view=rev
Log:
ELF: Move PLT relocation handler to one place. NFC.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259470&r1=259469&r2=259470&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Feb 2 01:07:34 2016
@@ -324,25 +324,36 @@ void Writer<ELFT>::scanRelocs(
continue;
}
- bool NeedsGot = false;
- bool NeedsPlt = false;
+ // If a relocation needs PLT, we create a PLT and a GOT slot
+ // for the symbol.
+ if (Body && Target->needsPlt(Type, *Body)) {
+ if (Body->isInPlt())
+ continue;
+ Out<ELFT>::Plt->addEntry(Body);
- if (Body) {
- NeedsPlt = Target->needsPlt(Type, *Body);
- if (NeedsPlt) {
- if (Body->isInPlt())
+ if (Target->UseLazyBinding) {
+ Out<ELFT>::GotPlt->addEntry(Body);
+ Out<ELFT>::RelaPlt->addReloc({&C, &RI});
+ } else {
+ if (Body->isInGot())
continue;
- Out<ELFT>::Plt->addEntry(Body);
+ Out<ELFT>::Got->addEntry(Body);
+ Out<ELFT>::RelaDyn->addReloc({&C, &RI});
}
+
+ if (canBePreempted(Body, /*NeedsGot=*/true))
+ Body->setUsedInDynamicReloc();
+ continue;
+ }
+
+ bool NeedsGot = false;
+
+ if (Body) {
NeedsGot = Target->needsGot(Type, *Body);
if (NeedsGot) {
- if (NeedsPlt && Target->UseLazyBinding) {
- Out<ELFT>::GotPlt->addEntry(Body);
- } else {
- if (Body->isInGot())
- continue;
- Out<ELFT>::Got->addEntry(Body);
- }
+ if (Body->isInGot())
+ continue;
+ Out<ELFT>::Got->addEntry(Body);
}
}
@@ -383,10 +394,7 @@ void Writer<ELFT>::scanRelocs(
if (CBP)
Body->setUsedInDynamicReloc();
- if (NeedsPlt && Target->UseLazyBinding)
- Out<ELFT>::RelaPlt->addReloc({&C, &RI});
- else
- Out<ELFT>::RelaDyn->addReloc({&C, &RI});
+ Out<ELFT>::RelaDyn->addReloc({&C, &RI});
}
}
More information about the llvm-commits
mailing list