<div dir="ltr">Yes, it says that the field is optional, but it doesn't say that it should be interpreted as zero if absent. So it seems to me that writing zero is the right thing if it is actually zero.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 29, 2016 at 2:06 PM, Eugene Leviant <span dir="ltr"><<a href="mailto:evgeny.leviant@gmail.com" target="_blank">evgeny.leviant@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">evgeny777 added inline comments.<br>
<span class=""><br>
================<br>
Comment at: ELF/OutputSections.cpp:672-674<br>
@@ -664,1 +671,5 @@<br>
+<br>
+    size_t NumRelativeRels = Out<ELFT>::RelaDyn-><wbr>getRelativeRelocCount();<br>
+    if (Config->ZCombreloc && NumRelativeRels)<br>
+      Add({IsRela ? DT_RELACOUNT : DT_RELCOUNT, NumRelativeRels});<br>
   }<br>
----------------<br>
</span><span class="">ruiu wrote:<br>
> I'm not sure if it is the right thing to not emit DT_REL[A]COUNT if there are no relative relocations. If the number of relative relocations is zero, shouldn't we write zero?<br>
</span>This doc:<br>
<a href="https://docs.oracle.com/cd/E19957-01/806-0641/6j9vuqujs/index.html" rel="noreferrer" target="_blank">https://docs.oracle.com/cd/<wbr>E19957-01/806-0641/6j9vuqujs/<wbr>index.html</a><br>
<br>
Says that DT_RELACOUNT is an optional field. Our dynamic linker assumes that number of relative relocs is zero, unless there is a DT_REL(A)COUNT tag. That said, I don't see any reason for writing it always.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D23661" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D23661</a><br>
<br>
<br>
<br>
</blockquote></div><br></div>