<div dir="ltr">Nice. Thanks.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 1, 2016 at 7:14 AM, Rafael Espindola via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Fri Apr 1 09:14:48 2016<br>
New Revision: 265142<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=265142&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=265142&view=rev</a><br>
Log:<br>
Refactor duplicated code.<br>
<br>
We had almost identical code to handle creating a plt entry in two<br>
places.<br>
<br>
Modified:<br>
lld/trunk/ELF/Writer.cpp<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=265142&r1=265141&r2=265142&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=265142&r1=265141&r2=265142&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Fri Apr 1 09:14:48 2016<br>
@@ -384,27 +384,6 @@ void Writer<ELFT>::scanRelocs(InputSecti<br>
}<br>
}<br>
<br>
- // An STT_GNU_IFUNC symbol always uses a PLT entry, and all references<br>
- // to the symbol go through the PLT. This is true even for a local<br>
- // symbol, although local symbols normally do not require PLT entries.<br>
- if (Body.IsGnuIFunc) {<br>
- if (Body.isInPlt())<br>
- continue;<br>
- Out<ELFT>::Plt->addEntry(Body);<br>
- if (Target->UseLazyBinding) {<br>
- Out<ELFT>::GotPlt->addEntry(Body);<br>
- Out<ELFT>::RelaPlt->addReloc(<br>
- {Preemptible ? Target->PltRel : Target->IRelativeRel,<br>
- DynamicReloc<ELFT>::Off_GotPlt, !Preemptible, &Body});<br>
- } else {<br>
- Out<ELFT>::Got->addEntry(Body);<br>
- Out<ELFT>::RelaDyn->addReloc(<br>
- {Preemptible ? Target->PltRel : Target->IRelativeRel,<br>
- DynamicReloc<ELFT>::Off_Got, !Preemptible, &Body});<br>
- }<br>
- continue;<br>
- }<br>
-<br>
// If a relocation needs PLT, we create a PLT and a GOT slot<br>
// for the symbol.<br>
TargetInfo::PltNeed NeedPlt = Target->needsPlt(Type, Body);<br>
@@ -415,16 +394,22 @@ void Writer<ELFT>::scanRelocs(InputSecti<br>
continue;<br>
Out<ELFT>::Plt->addEntry(Body);<br>
<br>
+ uint32_t Rel;<br>
+ if (Body.IsGnuIFunc)<br>
+ Rel = Preemptible ? Target->PltRel : Target->IRelativeRel;<br>
+ else<br>
+ Rel = Target->UseLazyBinding ? Target->PltRel : Target->GotRel;<br>
+<br>
if (Target->UseLazyBinding) {<br>
Out<ELFT>::GotPlt->addEntry(Body);<br>
Out<ELFT>::RelaPlt->addReloc(<br>
- {Target->PltRel, DynamicReloc<ELFT>::Off_GotPlt, &Body});<br>
+ {Rel, DynamicReloc<ELFT>::Off_GotPlt, !Preemptible, &Body});<br>
} else {<br>
if (Body.isInGot())<br>
continue;<br>
Out<ELFT>::Got->addEntry(Body);<br>
Out<ELFT>::RelaDyn->addReloc(<br>
- {Target->GotRel, DynamicReloc<ELFT>::Off_Got, &Body});<br>
+ {Rel, DynamicReloc<ELFT>::Off_Got, !Preemptible, &Body});<br>
}<br>
continue;<br>
}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>