<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">(reply inline; hopefully Outlook doesn't mess this up too badly)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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 <llvm-commits-bounces@lists.llvm.org> on behalf of Rafael Avila de Espindola via llvm-commits <llvm-commits@lists.llvm.org><br>
<b>Reply-To: </b>Rafael Avila de Espindola <rafael.espindola@gmail.com><br>
<b>Date: </b>Wednesday, January 10, 2018 at 7:45 PM<br>
<b>To: </b>"reviews+D41928+public+4e93109c06803cc3@reviews.llvm.org" <reviews+D41928+public+4e93109c06803cc3@reviews.llvm.org>, "rafael.espindola+phab@gmail.com" <rafael.espindola+phab@gmail.com>, "grimar@accesssoftek.com" <grimar@accesssoftek.com>, "ruiu@google.com"
 <ruiu@google.com><br>
<b>Cc: </b>"llvm-commits@lists.llvm.org" <llvm-commits@lists.llvm.org><br>
<b>Subject: </b>Re: [PATCH] D41928: [ELF] Fix SysV hash tables with --no-rosegment<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Shoaib Meenai via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> writes:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #B5C4DF 4.5pt;padding:0in 0in 0in 4.0pt;margin-left:3.75pt;margin-right:0in" id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE">
<div>
<p class="MsoNormal" style="margin-left:.5in">smeenai created this revision.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">smeenai added reviewers: espindola, grimar, ruiu.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Herald added a subscriber: emaste.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">When setting up the chain, we copy over the bucket's previous symbol<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">index, assuming that this index will be 0 (STN_UNDEF) for an unused<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">bucket (marking the end of the chain). When linking with --no-rosegment,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">however, unused buckets will in fact contain the padding value, and so<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">the hash table will end up containing invalid chains. Explicitly<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">zero-initialize the buckets to fix this problem. Also explicitly<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">zero-initialize the chain entry for STN_UNDEF; I don't think this is<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">actually necessary, but it doesn't hurt, and should make the hash table<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">identical both with and without --no-rosegment.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Repository:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">   rLLD LLVM Linker<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D41928&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=WNZ-Ei6GsCkrmsPagtyCCpRbriq-8qUz8JSmDjkMvMc&s=qXi5oGQEvi08zDlYOq7eDh0-VCKN7PIb-NxquZyecJg&e=">https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D41928&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=WNZ-Ei6GsCkrmsPagtyCCpRbriq-8qUz8JSmDjkMvMc&s=qXi5oGQEvi08zDlYOq7eDh0-VCKN7PIb-NxquZyecJg&e=</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Files:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">   ELF/SyntheticSections.cpp<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">   test/ELF/sysv-hash-no-rosegment.s<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Index: test/ELF/sysv-hash-no-rosegment.s<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">===================================================================<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">--- /dev/null<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+++ test/ELF/sysv-hash-no-rosegment.s<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">@@ -0,0 +1,13 @@<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# REQUIRES: x86<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# RUN: ld.lld -shared --no-rosegment -o %t %t.o<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# RUN: llvm-readobj -hash-table %t | FileCheck %s<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK:      HashTable {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK-NEXT:   Num Buckets: 2<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK-NEXT:   Num Chains: 2<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK-NEXT:   Buckets: [1, 0]<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK-NEXT:   Chains: [0, 0]<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+# CHECK-NEXT: }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+callq undef@PLT<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Index: ELF/SyntheticSections.cpp<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">===================================================================<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">--- ELF/SyntheticSections.cpp<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+++ ELF/SyntheticSections.cpp<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">@@ -1843,7 +1843,9 @@<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">    write32(P++, NumSymbols); // nchain<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">  <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">    uint32_t *Buckets = P;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">+  memset(Buckets, STN_UNDEF, NumSymbols * 4);<o:p></o:p></p>
</div>
</blockquote>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">I would just use 0 in here. Otherwise I get the impression that this<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">writes 4 *NumSymbols 32 values.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hmm. Should I use 0 for the other added line (below) as well then? That one is actually dealing with 32-bit quantities, but it seems weird to use 0 in one place and STN_UNDEF in another for what's conceptually supposed to be the same thing.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">+  Chains[STN_UNDEF] = STN_UNDEF;<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">LGTM with that.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Rafael<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">_______________________________________________<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">llvm-commits mailing list<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><o:p></o:p></p>
</div>
<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=WNZ-Ei6GsCkrmsPagtyCCpRbriq-8qUz8JSmDjkMvMc&s=teF1hX5flwteYpV8dviCoUz7kw7KKltbmyeN6xSn8yk&e=">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=WNZ-Ei6GsCkrmsPagtyCCpRbriq-8qUz8JSmDjkMvMc&s=teF1hX5flwteYpV8dviCoUz7kw7KKltbmyeN6xSn8yk&e=</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
</div>
</body>
</html>