[PATCH] D110490: [ELF] Support symbol names with space in linker script expressions
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 25 16:52:53 PDT 2021
MaskRay created this revision.
MaskRay added reviewers: jhenderson, peter.smith.
Herald added subscribers: arichardson, emaste.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Fix PR51961
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110490
Files:
lld/ELF/ScriptParser.cpp
lld/test/ELF/linkerscript/symbol-name.test
Index: lld/test/ELF/linkerscript/symbol-name.test
===================================================================
--- lld/test/ELF/linkerscript/symbol-name.test
+++ lld/test/ELF/linkerscript/symbol-name.test
@@ -8,8 +8,10 @@
# CHECK: Value Size Type Bind Vis Ndx Name
# CHECK-DAG: 0000000000000000 0 NOTYPE GLOBAL DEFAULT ABS a1
# CHECK-DAG: 0000000000000000 0 NOTYPE GLOBAL DEFAULT ABS a0
-# CHECK-DAG: 0000000000000003 0 NOTYPE GLOBAL DEFAULT ABS a2
+# CHECK-DAG: 0000000000000003 0 NOTYPE GLOBAL DEFAULT ABS a 2
+# CHECK-DAG: 0000000000000004 0 NOTYPE GLOBAL DEFAULT ABS a 3
a0 = DEFINED(.TOC.) ? .TOC. : 0;
"a1" = DEFINED(__global_pointer$) ? __global_pointer$ : 0;
-"a2" = DEFINED("a1") ? "a1" + 3 : 0;
+"a 2" = DEFINED("a1") ? "a1" + 3 : 0;
+"a 3" = "a 2" + 1;
Index: lld/ELF/ScriptParser.cpp
===================================================================
--- lld/ELF/ScriptParser.cpp
+++ lld/ELF/ScriptParser.cpp
@@ -1429,8 +1429,9 @@
return [=] { return *val; };
// Tok is a symbol name.
- tok = unquote(tok);
- if (!isValidSymbolName(tok))
+ if (tok.startswith("\""))
+ tok = unquote(tok);
+ else if (!isValidSymbolName(tok))
setError("malformed number: " + tok);
script->referencedSymbols.push_back(tok);
return [=] { return script->getSymbolValue(tok, location); };
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110490.375072.patch
Type: text/x-patch
Size: 1365 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210925/046c043f/attachment.bin>
More information about the llvm-commits
mailing list