<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60566>60566</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
No opt-out for LLD including own version in .comment section
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jonhoo
</td>
</tr>
</table>
<pre>
Since [D26487](https://reviews.llvm.org/D26487) / https://github.com/llvm/llvm-project/commit/3da3f06dd3a0e03053b5921e5dfcceffd9d7d399, LLD now includes its own version string in the `.comment` section of linked binaries:
```console
$ cat x.c
int main(void) {}
$ clang -fuse-ld=lld x.c
$ objdump -s -j .comment a.out
a.out: file format elf64-littleaarch64
Contents of section .comment:
0000 4c696e6b 65723a20 4c4c4420 31322e30 Linker: LLD 12.0
0010 2e310063 6c616e67 20766572 73696f6e .1.clang version
0020 2031312e 312e3020 28416d61 7a6f6e20 11.1.0 (Amazon
0030 4c696e75 78203220 31312e31 2e302d31 Linux 2 11.1.0-1
0040 2e616d7a 6e322e30 2e322900 4743433a .amzn2.0.2).GCC:
0050 2028474e 55292037 2e332e31 20323031 (GNU) 7.3.1 201
0060 38303731 32202852 65642048 61742037 80712 (Red Hat 7
0070 2e332e31 2d313529 0000 .3.1-15)..
```
Clang also does the same (via [D1720](https://reviews.llvm.org/D1720) and [D1729](https://reviews.llvm.org/D1729)), but provides an opt-out mechanism (like GCC) via `-fno-ident`/`-Qn` (they're equivalent in Clang):
```console
$ clang -fuse-ld=lld -Qn x.c
$ objdump -s -j .comment a.out
a.out: file format elf64-littleaarch64
Contents of section .comment:
0000 4c696e6b 65723a20 4c4c4420 31322e30 Linker: LLD 12.0
0010 2e310047 43433a20 28474e55 2920372e .1.GCC: (GNU) 7.
0020 332e3120 32303138 30373132 20285265 3.1 20180712 (Re
0030 64204861 7420372e 332e312d 31352900 d Hat 7.3.1-15).
0040 00 .
```
(note the absence of a clang version string)
However, LLD provides no such opt-out. Or if it does, it doesn't use the same argument as Clang, and I couldn't find another reference to such a command in any of the docs or in the D that landed the feature:
```console
$ clang -fuse-ld=lld -Qn -Xlinker -Qn x.c
ld.lld: error: unknown argument '-Qn'
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
$ clang -fuse-ld=lld -Qn -Xlinker -fno-ident x.c
ld.lld: error: unknown argument '-fno-ident'
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
```
I think the solution here is to add support for `-Qn` and switch on it somewhere around
https://github.com/llvm/llvm-project/blob/4b8fdb61afe3444e9b54c9c1d9fbb6cd928b9541/lld/ELF/SyntheticSections.cpp#L82-L91
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVk2P47gR_TX0pSCBLEqkdPBhpjveXaCxwWYQIFdKLLU5I5OOSLln9tcHlOSPDgbBDALkEMOwBYr16oP1XtHE6F490Z7VH1n9vDNzOoZp_zn4Ywi7Lthv-0_O9wSs_viMqmo0q58ZNseUzpHJDwwPDA8TXRy9xXIcL6cyTK8MD9tmbIHhAd5vf3XpOHdlH04MD9lm-yvOU_hMfWJ46MPp5PKDtEYOXFkrDScueS27ukVBtR36nobBtlZb2bYMn-Dl5Rl8eAPn-3G2FMGlCOHNw4Wm6IKHmCbnX8F5SEcCpniO4UQ-McUhUp_ypjDA6PwXstA5byZHS-D8mfHrr-Lrtw8-hpG2VaygNwm-lv264HyCk3GeYXMJzi6l0B-Zfn7YPxr_CsUwRypGy-TzONo7QN4Rus92Pp2hiFB8hmu4YMowp8eY1gX5AfJncCPBEKaTSUDjoKpidCmNZMzUH1X1aPcUfCKfyzTcCnAryjVt4JxzqHrVKlIdqFqjNJhXqr6qkIMUEpEkB3jJlZtyIPkwBJb8BiE4IEnBuZKgeiUUKQ3Itcp4oKVq1aAIoBTlWpft1G4AyAG5FFIgQf6Ry0pTCWWVAG2yOXIAEKIUJQeGzYeT-fMBQV6z0DXoBrnENfgMJmBBtFIsWcxfATegQt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