<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 4, 2016 at 3:51 AM, Simon Atanasyan 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: atanasyan<br>
Date: Thu Feb  4 05:51:45 2016<br>
New Revision: 259779<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=259779&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=259779&view=rev</a><br>
Log:<br>
[ELF][MIPS] Replace needsMipsLocalGot function by canBePreempted<br>
<br>
Symbol does not need an entry i the 'global' part of GOT if it cannot be<br>
preempted. So canBePreempted fully satisfies us at least for now.<br>
<br>
Modified:<br>
    lld/trunk/ELF/InputSection.cpp<br>
    lld/trunk/ELF/Target.cpp<br>
    lld/trunk/ELF/Target.h<br>
    lld/trunk/ELF/Writer.cpp<br>
<br>
Modified: lld/trunk/ELF/InputSection.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=259779&r1=259778&r2=259779&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=259779&r1=259778&r2=259779&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/InputSection.cpp (original)<br>
+++ lld/trunk/ELF/InputSection.cpp Thu Feb  4 05:51:45 2016<br>
@@ -209,7 +209,7 @@ void InputSectionBase<ELFT>::relocate(ui<br>
     if (Target->needsPlt(Type, *Body)) {<br>
       SymVA = Body->getPltVA<ELFT>();<br>
     } else if (Target->needsGot(Type, *Body)) {<br>
-      if (Config->EMachine == EM_MIPS && needsMipsLocalGot(Type, Body))<br>
+      if (Config->EMachine == EM_MIPS && !canBePreempted(Body, true))<br>
         // Under some conditions relocations against non-local symbols require<br>
         // entries in the local part of MIPS GOT. In that case we need an entry<br>
         // initialized by full address of the symbol.<br>
<br>
Modified: lld/trunk/ELF/Target.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=259779&r1=259778&r2=259779&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=259779&r1=259778&r2=259779&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Target.cpp (original)<br>
+++ lld/trunk/ELF/Target.cpp Thu Feb  4 05:51:45 2016<br>
@@ -1562,20 +1562,6 @@ template <class ELFT> typename ELFFile<E<br>
   return 0;<br>
 }<br>
<br>
-bool needsMipsLocalGot(uint32_t Type, SymbolBody *Body) {<br>
-  // The R_MIPS_GOT16 relocation requires creation of entry in the local part<br>
-  // of GOT if its target is a local symbol or non-local symbol with 'local'<br>
-  // visibility.<br>
-  if (Type != R_MIPS_GOT16)<br>
-    return false;<br>
-  if (!Body)<br>
-    return true;<br>
-  uint8_t V = Body->getVisibility();<br>
-  if (V != STV_DEFAULT && V != STV_PROTECTED)<br>
-    return true;<br>
-  return !Config->Shared;<br>
-}<br>
-<br>
 template bool isGnuIFunc<ELF32LE>(const SymbolBody &S);<br>
 template bool isGnuIFunc<ELF32BE>(const SymbolBody &S);<br>
 template bool isGnuIFunc<ELF64LE>(const SymbolBody &S);<br>
<br>
Modified: lld/trunk/ELF/Target.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=259779&r1=259778&r2=259779&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=259779&r1=259778&r2=259779&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Target.h (original)<br>
+++ lld/trunk/ELF/Target.h Thu Feb  4 05:51:45 2016<br>
@@ -98,9 +98,6 @@ uint64_t getPPC64TocBase();<br>
 template <class ELFT><br>
 typename llvm::object::ELFFile<ELFT>::uintX_t getMipsGpAddr();<br>
<br>
-// Returns true if the relocation requires entry in the local part of GOT.<br>
-bool needsMipsLocalGot(uint32_t Type, SymbolBody *Body);<br>
-<br>
 template <class ELFT> bool isGnuIFunc(const SymbolBody &S);<br>
<br>
 extern std::unique_ptr<TargetInfo> Target;<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259779&r1=259778&r2=259779&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259779&r1=259778&r2=259779&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Thu Feb  4 05:51:45 2016<br>
@@ -291,10 +291,12 @@ void Writer<ELFT>::scanRelocs(<br>
     }<br>
<br>
     // MIPS has a special rule to create GOTs for local symbols.<br>
-    if (Config->EMachine == EM_MIPS && needsMipsLocalGot(Type, Body)) {<br>
-      // FIXME (simon): Do not add so many redundant entries.<br>
-      Out<ELFT>::Got->addMipsLocalEntry();<br>
-      continue;<br>
+    if (Config->EMachine == EM_MIPS && !canBePreempted(Body, true)) {<br>
+      if (Type == R_MIPS_GOT16 || Type == R_MIPS_CALL16) {<br></blockquote><div><br></div><div>You can decrease the nesting level by one here.</div><br>if (Config->EMachine == EM_MIPS && !canBePreempted(Body, true) &&<br><div>    (Type == R_MIPS_GOT16 || Type == R_MIPS_CALL16)) {</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+        // FIXME (simon): Do not add so many redundant entries.<br>
+        Out<ELFT>::Got->addMipsLocalEntry();<br>
+        continue;<br>
+      }<br>
     }<br>
<br>
     // If a symbol in a DSO is referenced directly instead of through GOT,<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></div>