[lld] r265142 - Refactor duplicated code.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 1 09:19:50 PDT 2016
Nice. Thanks.
On Fri, Apr 1, 2016 at 7:14 AM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: rafael
> Date: Fri Apr 1 09:14:48 2016
> New Revision: 265142
>
> URL: http://llvm.org/viewvc/llvm-project?rev=265142&view=rev
> Log:
> Refactor duplicated code.
>
> We had almost identical code to handle creating a plt entry in two
> places.
>
> 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=265142&r1=265141&r2=265142&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Writer.cpp (original)
> +++ lld/trunk/ELF/Writer.cpp Fri Apr 1 09:14:48 2016
> @@ -384,27 +384,6 @@ void Writer<ELFT>::scanRelocs(InputSecti
> }
> }
>
> - // An STT_GNU_IFUNC symbol always uses a PLT entry, and all references
> - // to the symbol go through the PLT. This is true even for a local
> - // symbol, although local symbols normally do not require PLT entries.
> - if (Body.IsGnuIFunc) {
> - if (Body.isInPlt())
> - continue;
> - Out<ELFT>::Plt->addEntry(Body);
> - if (Target->UseLazyBinding) {
> - Out<ELFT>::GotPlt->addEntry(Body);
> - Out<ELFT>::RelaPlt->addReloc(
> - {Preemptible ? Target->PltRel : Target->IRelativeRel,
> - DynamicReloc<ELFT>::Off_GotPlt, !Preemptible, &Body});
> - } else {
> - Out<ELFT>::Got->addEntry(Body);
> - Out<ELFT>::RelaDyn->addReloc(
> - {Preemptible ? Target->PltRel : Target->IRelativeRel,
> - DynamicReloc<ELFT>::Off_Got, !Preemptible, &Body});
> - }
> - continue;
> - }
> -
> // If a relocation needs PLT, we create a PLT and a GOT slot
> // for the symbol.
> TargetInfo::PltNeed NeedPlt = Target->needsPlt(Type, Body);
> @@ -415,16 +394,22 @@ void Writer<ELFT>::scanRelocs(InputSecti
> continue;
> Out<ELFT>::Plt->addEntry(Body);
>
> + uint32_t Rel;
> + if (Body.IsGnuIFunc)
> + Rel = Preemptible ? Target->PltRel : Target->IRelativeRel;
> + else
> + Rel = Target->UseLazyBinding ? Target->PltRel : Target->GotRel;
> +
> if (Target->UseLazyBinding) {
> Out<ELFT>::GotPlt->addEntry(Body);
> Out<ELFT>::RelaPlt->addReloc(
> - {Target->PltRel, DynamicReloc<ELFT>::Off_GotPlt, &Body});
> + {Rel, DynamicReloc<ELFT>::Off_GotPlt, !Preemptible, &Body});
> } else {
> if (Body.isInGot())
> continue;
> Out<ELFT>::Got->addEntry(Body);
> Out<ELFT>::RelaDyn->addReloc(
> - {Target->GotRel, DynamicReloc<ELFT>::Off_Got, &Body});
> + {Rel, DynamicReloc<ELFT>::Off_Got, !Preemptible, &Body});
> }
> continue;
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160401/cc449ff5/attachment.html>
More information about the llvm-commits
mailing list