diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-02-02 07:07:34 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-02-02 07:07:34 +0000 |
| commit | 554f273b9d629fccfeada1442cd2274d88181df1 (patch) | |
| tree | 2d36e8497a470ccf88d00440ea677fb1ea01b004 | |
| parent | ccc809e2e60fbcf519b3945bc33e92b9093405f1 (diff) | |
| download | bcm5719-llvm-554f273b9d629fccfeada1442cd2274d88181df1.tar.gz bcm5719-llvm-554f273b9d629fccfeada1442cd2274d88181df1.zip | |
ELF: Move PLT relocation handler to one place. NFC.
llvm-svn: 259470
| -rw-r--r-- | lld/ELF/Writer.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index a09a570384f..1371a96236d 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -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}); } } |

