<p dir="ltr">Thanks!</p>
<div class="gmail_quote">On Jan 29, 2016 5:59 PM, "Rui Ueyama via llvm-commits" <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Fri Jan 29 16:55:38 2016<br>
New Revision: 259259<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=259259&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=259259&view=rev</a><br>
Log:<br>
Add comments on a mysterious value in MIPS GOT[1].<br>
<br>
Thanks to Simon Atanasyan and Igor Kudrin for describing the code!<br>
<br>
Modified:<br>
    lld/trunk/ELF/Target.cpp<br>
<br>
Modified: lld/trunk/ELF/Target.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=259259&r1=259258&r2=259259&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=259259&r1=259258&r2=259259&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Target.cpp (original)<br>
+++ lld/trunk/ELF/Target.cpp Fri Jan 29 16:55:38 2016<br>
@@ -1408,9 +1408,24 @@ unsigned MipsTargetInfo<ELFT>::getDynRel<br>
 template <class ELFT><br>
 void MipsTargetInfo<ELFT>::writeGotHeader(uint8_t *Buf) const {<br>
   typedef typename ELFFile<ELFT>::Elf_Off Elf_Off;<br>
+  typedef typename ELFFile<ELFT>::uintX_t uintX_t;<br>
+<br>
+  // Set the MSB of the second GOT slot. This is not required by any<br>
+  // MIPS ABI documentation, though.<br>
+  //<br>
+  // There is a comment in glibc saying that "The MSB of got[1] of a<br>
+  // gnu object is set to identify gnu objects," and in GNU gold it<br>
+  // says "the second entry will be used by some runtime loaders".<br>
+  // But how this field is being used is unclear.<br>
+  //<br>
+  // We are not really willing to mimic other linkers behaviors<br>
+  // without understanding why they do that, but because all files<br>
+  // generated by GNU tools have this special GOT value, and because<br>
+  // we've been doing this for years, it is probably a safe bet to<br>
+  // keep doing this for now. We really need to revisit this to see<br>
+  // if we had to do this.<br>
   auto *P = reinterpret_cast<Elf_Off *>(Buf);<br>
-  // Module pointer<br>
-  P[1] = ELFT::Is64Bits ? 0x8000000000000000 : 0x80000000;<br>
+  P[1] = uintX_t(1) << (ELFT::Is64Bits ? 63 : 31);<br>
 }<br>
<br>
 template <class ELFT><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>