<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118047>118047</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LLD] Unary '+' operator is not supported in linker script
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
partaror
</td>
</tr>
</table>
<pre>
LLD does not support unary '+' operator in linker scripts. We should perhaps support this for compatibility with GNU linker.
Reproducible example:
```bash
#!/usr/bin/env bash
cat >1.c <<\EOF
int foo() { return 1; }
int bar() { return 3; }
EOF
cat >script.t <<\EOF
val = +0x1;
EOF
clang-18 -o 1.o 1.c -c -ffunction-sections
ld.bfd -o 1.bdf.out 1.o -T script.t
ld.lld -o 1.lld.out 1.o -T script.t
```
GNU LD produces no error, whereas LLD reports:
```
ld.lld: error: script.t:1: malformed number: +
>>> val = +0x1;
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0U09vnD4Q_TTDZQTyHwjLgQMbwu-y-lWqGvVsg1ncGoxss0m-fQVsdpWmkQZZlt_MY-bNE97r86RUCdkRsjoSSxisK2fhgnDWRdJ2b-XpVGNnlcfJBvTLPFsXcJmEe0NgObAjsBztrJwI1qGe0Ojpt3LoW6fn4BP8qdAPdjEdzsoNYva3KmHQHnvrsLXjLIKW2ujwhi86DPjf_8_XSgmQCkj1Xc3OdkurpVGoXsU4GwW82h_hgewhhR_WO-PAKLBm8Q5YI_UErFHTBd_fSdWKgMCfaNIi8Mc1ssenbw2QSk8Be2uBHYAVCPkRnQqLm5ACPyLk9RUjhfuM4XfMXu1OtU8kCX_zXYRB4DUCO5LXleNDrhHTOaYHjC3SZP1ajFuM-36Z2qDtFHu1nR5IZbpE9t0OlV2f2CVsSfEPfCffUcZcUcZ0X6BuI93_Y9XjVOOuwbYNqJyzDtgjvgzKKeFxXRWnVmn9Z2VuxMCrayqv7oS8out9FKa3blQdTsso1YZZd4xUwJ_2wH_N60YTdSXvCl6ISJU05-yQcZKn0VAe8kL1LJe0a9MDpT1nImN5qgqpSMEKGemSEZZSygqSkpSnCe-pTDNOCvJAi45mkBI1Cm0SYy5jYt050t4vqqT0QNI8MkIq4zcvMbb2ydhqKleu8FguZw8pMdoHfy8QdDCb_U6nGrIan7_01Qf_qe6T0aLFmXIIYd5GzxpgzVmHYZFJa0dgzUp5PeLZ2V-qDcCarQEPrLn2cCnZnwAAAP__E3E6pw">