<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - quotes in linker script symbol names incorrectly retained"
href="https://bugs.llvm.org/show_bug.cgi?id=51961">51961</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>quotes in linker script symbol names incorrectly retained
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>ELF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>vapier@gentoo.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com
</td>
</tr></table>
<p>
<div>
<pre>from the GNU linker docs:
<span class="quote">> <a href="https://sourceware.org/binutils/docs/ld.html#Symbols">https://sourceware.org/binutils/docs/ld.html#Symbols</a>
> Unless quoted, symbol names start with a letter, underscore, or period and
> may include letters, digits, underscores, periods, and hyphens. Unquoted
> symbol names must not conflict with any keywords. You can specify a symbol
> which contains odd characters or has the same name as a keyword by
> surrounding the symbol name in double quotes:
>
> "SECTION" = 9;
> "with a space" = "also with a space" + 10;</span >
simple test case:
$ cat test.c
int main(){}
$ cat test.lds
symtest1 = 1;
"symtest2" = 2;
"symtest3" = "symtest1";
"symtest@3" = 3;
"symtest@4" = symtest1;
"symtest@5" = "symtest1";
"symtest 6" = 6;
"symtest 7" = "symtest 6";
checking with ld.bfd looks correct:
$ clang test.c -fuse-ld=bfd test.lds
$ readelf -sW a.out | grep symtest
3: 0000000000000003 0 NOTYPE LOCAL DEFAULT ABS symtest@3
4: 0000000000000001 0 NOTYPE LOCAL DEFAULT ABS symtest@5
5: 0000000000000001 0 NOTYPE LOCAL DEFAULT ABS symtest@4
14: 0000000000000002 0 NOTYPE GLOBAL DEFAULT ABS symtest2
15: 0000000000000006 0 NOTYPE GLOBAL DEFAULT ABS symtest 6
24: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS symtest3
26: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS symtest1
27: 0000000000000006 0 NOTYPE GLOBAL DEFAULT ABS symtest 7
using lld fails outright due to RHS quoting:
$ clang test.c -fuse-ld=lld test.lds
ld.lld: error: test.lds:3: malformed number: "symtest1"
<span class="quote">>>> "symtest3" = "symtest1";
>>> ^</span >
clang-12: error: linker command failed with exit code 1 (use -v to see
invocation)
but even after removing those shows lld generates invalid symbols:
$ readelf -sW a.out | grep symtest
16: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS symtest1
17: 0000000000000002 0 NOTYPE GLOBAL DEFAULT ABS "symtest2"
18: 0000000000000003 0 NOTYPE GLOBAL DEFAULT ABS "symtest@3"
19: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS "symtest@4"
20: 0000000000000006 0 NOTYPE GLOBAL DEFAULT ABS "symtest 6"</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>