<div dir="ltr">Approved.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 10, 2018 at 10:58 PM, Shoaib Meenai <span dir="ltr"><<a href="mailto:smeenai@fb.com" target="_blank">smeenai@fb.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">







<div bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="m_-5639814288329294636WordSection1">
<p class="MsoNormal">Requesting a merge to 6.0.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">llvm-commits <<a href="mailto:llvm-commits-bounces@lists.llvm.org" target="_blank">llvm-commits-bounces@lists.<wbr>llvm.org</a>> on behalf of Shoaib Meenai via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>><br>
<b>Reply-To: </b>Shoaib Meenai <<a href="mailto:smeenai@fb.com" target="_blank">smeenai@fb.com</a>><br>
<b>Date: </b>Wednesday, January 10, 2018 at 10:58 PM<br>
<b>To: </b>"<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>" <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>><br>
<b>Subject: </b>[lld] r322259 - [ELF] Fix SysV hash tables with --no-rosegment<u></u><u></u></span></p>
</div><span class="">
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Author: smeenai<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Date: Wed Jan 10 22:57:01 2018<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">New Revision: 322259<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
</span><div>
<p class="MsoNormal" style="margin-left:.5in">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D322259-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TzrIlS-6umMNRBVgupRbtxnFD-cXXbaxjd-gc8JgZcw&s=3Y89oPU0NvdG7K6lOFdJV5V8EZeTYfpNxkgb3JOIiEQ&e=" target="_blank">
https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject-<wbr>3Frev-3D322259-26view-3Drev&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>TzrIlS-6umMNRBVgupRbtxnFD-<wbr>cXXbaxjd-gc8JgZcw&s=<wbr>3Y89oPU0NvdG7K6lOFdJV5V8EZeTYf<wbr>pNxkgb3JOIiEQ&e=</a><u></u><u></u></p>
</div><span class="">
<div>
<p class="MsoNormal" style="margin-left:.5in">Log:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">[ELF] Fix SysV hash tables with --no-rosegment<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">When setting up the chain, we copy over the bucket's previous symbol<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">index, assuming that this index will be 0 (STN_UNDEF) for an unused<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">bucket (marking the end of the chain). When linking with --no-rosegment,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">however, unused buckets will in fact contain the padding value, and so<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">the hash table will end up containing invalid chains. Zero out the hash<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">table section explicitly to avoid this, similar to what's already done<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">for GNU hash sections.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
</span><div>
<p class="MsoNormal" style="margin-left:.5in">Differential Revision: <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D41928&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TzrIlS-6umMNRBVgupRbtxnFD-cXXbaxjd-gc8JgZcw&s=8qLiJg_KJkyadNiH7iVdh1Ab9J2tTu3wPrSxx_VYhGk&e=" target="_blank">
https://urldefense.proofpoint.<wbr>com/v2/url?u=https-3A__<wbr>reviews.llvm.org_D41928&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>TzrIlS-6umMNRBVgupRbtxnFD-<wbr>cXXbaxjd-gc8JgZcw&s=8qLiJg_<wbr>KJkyadNiH7iVdh1Ab9J2tTu3wPrSxx<wbr>_VYhGk&e=</a><u></u><u></u></p>
</div><span class="">
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Added:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">    lld/trunk/test/ELF/sysv-<wbr>hash-no-rosegment.s<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Modified:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">    lld/trunk/ELF/<wbr>SyntheticSections.cpp<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Modified: lld/trunk/ELF/<wbr>SyntheticSections.cpp<u></u><u></u></p>
</div>
</span><div>
<p class="MsoNormal" style="margin-left:.5in">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_SyntheticSections.cpp-3Frev-3D322259-26r1-3D322258-26r2-3D322259-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TzrIlS-6umMNRBVgupRbtxnFD-cXXbaxjd-gc8JgZcw&s=Csr47xs-UR1RtF4_oipHeeHvguaFAWBjbu_BF-eGMmY&e=" target="_blank">
https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_SyntheticSections.<wbr>cpp-3Frev-3D322259-26r1-<wbr>3D322258-26r2-3D322259-26view-<wbr>3Ddiff&d=DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>TzrIlS-6umMNRBVgupRbtxnFD-<wbr>cXXbaxjd-gc8JgZcw&s=Csr47xs-<wbr>UR1RtF4_oipHeeHvguaFAWBjbu_BF-<wbr>eGMmY&e=</a><u></u><u></u></p>
</div><span class="">
<div>
<p class="MsoNormal" style="margin-left:.5in">==============================<wbr>==============================<wbr>==================<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">--- lld/trunk/ELF/<wbr>SyntheticSections.cpp (original)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+++ lld/trunk/ELF/<wbr>SyntheticSections.cpp Wed Jan 10 22:57:01 2018<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">@@ -1836,6 +1836,9 @@ void HashTableSection::<wbr>finalizeContents(<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">}<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">void HashTableSection::writeTo(<wbr>uint8_t *Buf) {<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+  // See comment in GnuHashTableSection::writeTo.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+  memset(Buf, 0, Size);<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">   unsigned NumSymbols = InX::DynSymTab->getNumSymbols(<wbr>);<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">   uint32_t *P = reinterpret_cast<uint32_t *>(Buf);<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Added: lld/trunk/test/ELF/sysv-hash-<wbr>no-rosegment.s<u></u><u></u></p>
</div>
</span><div>
<p class="MsoNormal" style="margin-left:.5in">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_sysv-2Dhash-2Dno-2Drosegment.s-3Frev-3D322259-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TzrIlS-6umMNRBVgupRbtxnFD-cXXbaxjd-gc8JgZcw&s=0bbiAHcIR4yTXv2MSkubnqN6lLXgm4QYw7TElwgAPKk&e=" target="_blank">
https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_test_ELF_sysv-2Dhash-<wbr>2Dno-2Drosegment.s-3Frev-<wbr>3D322259-26view-3Dauto&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>TzrIlS-6umMNRBVgupRbtxnFD-<wbr>cXXbaxjd-gc8JgZcw&s=<wbr>0bbiAHcIR4yTXv2MSkubnqN6lLXgm4<wbr>QYw7TElwgAPKk&e=</a><u></u><u></u></p>
</div><span class="">
<div>
<p class="MsoNormal" style="margin-left:.5in">==============================<wbr>==============================<wbr>==================<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">--- lld/trunk/test/ELF/sysv-hash-<wbr>no-rosegment.s (added)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+++ lld/trunk/test/ELF/sysv-hash-<wbr>no-rosegment.s Wed Jan 10 22:57:01 2018<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">@@ -0,0 +1,13 @@<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# REQUIRES: x86<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# RUN: ld.lld -shared --no-rosegment -o %t %t.o<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# RUN: llvm-readobj -hash-table %t | FileCheck %s<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK:      HashTable {<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK-NEXT:   Num Buckets: 2<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK-NEXT:   Num Chains: 2<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK-NEXT:   Buckets: [1, 0]<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK-NEXT:   Chains: [0, 0]<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK-NEXT: }<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+callq undef@PLT<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">______________________________<wbr>_________________<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">llvm-commits mailing list<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><u></u><u></u></p>
</div>
</span><div>
<p class="MsoNormal" style="margin-left:.5in"><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TzrIlS-6umMNRBVgupRbtxnFD-cXXbaxjd-gc8JgZcw&s=jcgUz94QCn22TBZVnEgVpJ7NSgqjghv1AjGNKpmlbmk&e=" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__lists.<wbr>llvm.org_cgi-2Dbin_mailman_<wbr>listinfo_llvm-2Dcommits&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>TzrIlS-6umMNRBVgupRbtxnFD-<wbr>cXXbaxjd-gc8JgZcw&s=<wbr>jcgUz94QCn22TBZVnEgVpJ7NSgqjgh<wbr>v1AjGNKpmlbmk&e=</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><u></u> <u></u></p>
</div>
</div>
</div>

</blockquote></div><br></div>