[llvm-bugs] [Bug 51961] New: quotes in linker script symbol names incorrectly retained
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 24 13:41:55 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51961
Bug ID: 51961
Summary: quotes in linker script symbol names incorrectly
retained
Product: lld
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: ELF
Assignee: unassignedbugs at nondot.org
Reporter: vapier at gentoo.org
CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com
from the GNU linker docs:
> https://sourceware.org/binutils/docs/ld.html#Symbols
> 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;
simple test case:
$ cat test.c
int main(){}
$ cat test.lds
symtest1 = 1;
"symtest2" = 2;
"symtest3" = "symtest1";
"symtest at 3" = 3;
"symtest at 4" = symtest1;
"symtest at 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 at 3
4: 0000000000000001 0 NOTYPE LOCAL DEFAULT ABS symtest at 5
5: 0000000000000001 0 NOTYPE LOCAL DEFAULT ABS symtest at 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"
>>> "symtest3" = "symtest1";
>>> ^
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 at 3"
19: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS "symtest at 4"
20: 0000000000000006 0 NOTYPE GLOBAL DEFAULT ABS "symtest 6"
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210924/e6d869d6/attachment.html>
More information about the llvm-bugs
mailing list