<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000'><br><hr id="zwchr"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Mehdi Amini" <mehdi.amini@apple.com><br><b>To: </b>"Hal Finkel" <hfinkel@anl.gov><br><b>Cc: </b>"llvm-dev" <llvm-dev@lists.llvm.org>, "Rui Ueyama" <ruiu@google.com><br><b>Sent: </b>Tuesday, October 18, 2016 11:35:02 PM<br><b>Subject: </b>Re: [llvm-dev] Embedding LLD version to executables<br><br>
<br class=""><div><blockquote class=""><div class="">On Oct 18, 2016, at 9:27 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><hr id="zwchr" style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><blockquote style="font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" class=""><b class="">From:<span class="Apple-converted-space"> </span></b>"Mehdi Amini" <<a href="mailto:mehdi.amini@apple.com" class="" target="_blank">mehdi.amini@apple.com</a>><br class=""><b class="">To:<span class="Apple-converted-space"> </span></b>"Hal Finkel" <<a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>><br class=""><b class="">Cc:<span class="Apple-converted-space"> </span></b>"llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" class="" target="_blank">llvm-dev@lists.llvm.org</a>>, "Rui Ueyama" <<a href="mailto:ruiu@google.com" class="" target="_blank">ruiu@google.com</a>><br class=""><b class="">Sent:<span class="Apple-converted-space"> </span></b>Tuesday, October 18, 2016 10:38:57 PM<br class=""><b class="">Subject:<span class="Apple-converted-space"> </span></b>Re: [llvm-dev] Embedding LLD version to executables<br class=""><br class=""><br class=""><div id="DWT1762" class=""><blockquote class=""><div class="">On Oct 18, 2016, at 8:30 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;"><hr id="zwchr" class=""></span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><blockquote class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">From: "Mehdi Amini via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" class="" target="_blank">llvm-dev@lists.llvm.org</a>><br class="">To: "Rui Ueyama" <<a href="mailto:ruiu@google.com" class="" target="_blank">ruiu@google.com</a>><br class="">Cc: "llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" class="" target="_blank">llvm-dev@lists.llvm.org</a>><br class="">Sent: Tuesday, October 18, 2016 10:22:00 PM<br class="">Subject: Re: [llvm-dev] Embedding LLD version to executables<br class=""><br class=""><br class=""><blockquote class="">On Oct 18, 2016, at 6:44 PM, Rui Ueyama via llvm-dev<br class=""><<a href="mailto:llvm-dev@lists.llvm.org" class="" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br class=""><br class="">I'd like to make LLD embed version information so that we can<br class="">determine if an executable was created by LLD and if that's the<br class="">case which version of LLD.<br class=""></blockquote><br class="">Pardon my ignorance, but what’s the motivation?<br class=""><br class="">We don’t embed the clang version in every binary clang generates for<br class="">instance.<br class=""></blockquote><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;">We do. Clang outputs an "ident" comment with its version information, and that ends up in the object files (at least on Linux).</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"></div></blockquote><div class=""><br class=""></div><div class="">Interesting, we don’t on Darwin:</div><div class=""><br class=""></div><div class="">$ echo "int main() {}" | clang -x c -o - - -S  | grep clang</div><div class="">$ echo "int main() {}" | clang -x c -o - - -S -target x86_64-pc-linux-gnu | grep clang</div><span class="Apple-tab-span" style="white-space: pre;">     </span>.ident<span class="Apple-tab-span" style="white-space: pre;">    </span>"Apple LLVM version 8.0.0 (clang-800.0.42.1)”<br class=""><br class="">Dos it show up in the final binary?</div></blockquote><span style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">Yes</span><br style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><blockquote style="font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" class=""><div id="DWT1763" class="">If yes, how does it behave when you mix-and-match versions in different .o?</div></blockquote><span style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">I see both versions in the final binary.</span><br style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""></div></blockquote><div><br class=""></div><div>Pretty cool! Thanks for looking.</div><div><br class=""></div><div id="DWT1868">Is there a trace in the binary the list of object files for each version? I guess that’d be more costly to store.</div></div></blockquote>As far as I can tell, the version strings all get concatenated in the .comment section of the resulting executable. The strings are null-terminated, and so there is a null byte separating the strings. For example, objdump -x -s shows this from my test:<br><br>Contents of section .comment:<br> 0000 4743433a 2028474e 55292034 2e382e35  GCC: (GNU) 4.8.5<br> 0010 20323031 35303632 33202852 65642048   20150623 (Red H<br> 0020 61742034 2e382e35 2d342900 636c616e  at 4.8.5-4).clan<br> 0030 67207665 7273696f 6e20342e 302e3020  g version 4.0.0 <br> 0040 28687474 703a2f2f 6c6c766d 2e6f7267  (http://llvm.org<br> 0050 2f676974 2f636c61 6e672e67 69742036  /git/clang.git 6<br> 0060 31653732 36613362 63633664 34633262  1e726a3bcc6d4c2b<br> 0070 35346330 30366337 61623762 31316133  54c006c7ab7b11a3<br> 0080 33613034 32613629 20286874 74703a2f  3a042a6) (http:/<br> 0090 2f6c6c76 6d2e6f72 672f6769 742f6c6c  /llvm.org/git/ll<br> 00a0 766d2e67 69742061 62383338 37303961  vm.git ab838709a<br> 00b0 63356330 35623262 36393031 65366630  c5c05b2b6901e6f0<br> 00c0 65303964 65613561 35356636 36333729  e09dea5a55f6637)<br> 00d0 00636c61 6e672076 65727369 6f6e2033  .clang version 3<br> 00e0 2e392e30 20286874 74703a2f 2f6c6c76  .9.0 (http://llv<br> 00f0 6d2e6f72 672f6769 742f636c 616e672e  m.org/git/clang.<br> 0100 67697420 30373330 37663935 64356338  git 07307f95d5c8<br> 0110 32643435 33636463 35633233 66396363  2d453cdc5c23f9cc<br> 0120 64353364 35666637 35343236 29202868  d53d5ff75426) (h<br> 0130 7474703a 2f2f6c6c 766d2e6f 72672f67  ttp://llvm.org/g<br> 0140 69742f6c 6c766d2e 67697420 30333136  it/llvm.git 0316<br> 0150 66303235 64616234 36643737 36646565  f025dab46d776dee<br> 0160 37306433 62363935 65316130 37646235  70d3b695e1a07db5<br> 0170 33373163 2900                        371c).          <br><br> -Hal<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div><div></div><div><br class=""></div><div>— </div><div>Mehdi</div><blockquote class=""><div class=""><blockquote style="font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Also I’m still not sure why doing this?</div><div class=""><br class=""></div><div class="">— </div><div class="">Mehdi<br class=""><br class=""><blockquote class=""><div class=""><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><blockquote class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br class=""><blockquote class=""><br class="">ld.bfd doesn't seem to embed any information, so we cannot tell<br class="">whether an executable was linked by ld.bfd or not easily.<br class=""><br class="">ld.gold embeds a string "GNU gold <version>" as<br class="">".note.gnu.gold-version" section contents.<br class=""><br class="">I'm wondering what we should do for LLD. The gold's way seems<br class="">almost right, but I think we don't want to use the same section<br class="">name because it contains "gold" as part of the section name.<br class="">However, at the same time, I don't believe we want to create<br class="">".note.gnu.lld-version", because if we do, all programs that<br class="">determine linker version need to look at<br class="">".note.gnu.<linker-name>-version" for all known linkers. That's<br class="">absurd. (Also, our product is not GNU, so ".gnu" part is probably<br class="">irrelevant.)<br class=""><br class="">I'm leaning towards ".note.linker-version" in hope that other<br class="">linkers follow it.<br class=""></blockquote><br class="">At least that would look much better than a .gnu.xxxx<br class=""></blockquote><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;">I agree.</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;">-Hal</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><blockquote class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br class="">—<br class="">Mehdi<br class=""><br class=""><br class="">_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="" target="_blank">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""><br class=""></blockquote><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;">--<span class="Apple-converted-space"> </span></span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;">Hal Finkel</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;">Lead, Compiler Technology and Programming Languages</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;">Leadership Computing Facility</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;">Argonne National Laboratory</span></div></blockquote></div><br class=""></blockquote><br style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">--<span class="Apple-converted-space"> </span></span><br style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><div style="font-family: arial,helvetica,sans-serif; font-size: 13.3333px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span class=""></span>Hal Finkel<br class="">Lead, Compiler Technology and Programming Languages<br class="">Leadership Computing Facility<br class="">Argonne National Laboratory<span class=""></span><br class=""></div></div></blockquote></div><br class=""></blockquote><br><br><br>-- <br><div><span name="x"></span>Hal Finkel<br>Lead, Compiler Technology and Programming Languages<br>Leadership Computing Facility<br>Argonne National Laboratory<span name="x"></span><br></div></div></body></html>