aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2019-02-11 22:01:32 +0000
committerRui Ueyama <ruiu@google.com>2019-02-11 22:01:32 +0000
commit2cfa2ff84ac8faa091d3ca042f2beea2f53b58ff (patch)
treef8d0c4d04f222fcae2f89c3045cfffb876b76a99
parent83a25ddffc9d0ac9abe713a9d57b978177594c70 (diff)
downloadlld-2cfa2ff84ac8faa091d3ca042f2beea2f53b58ff.tar.gz
lld: unquote possibly quoted `EXTERN("symbol")` entry in linker script.
gold accepts quoted strings. binutils requires quoted strings for some kinds of symbols, e.g.: it accepts quoted symbols with @ in name: $ echo 'EXTERN("__libc_start_main@@GLIBC_2.2.5")' > a.script $ g++ a.script /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status but rejects them if unquoted: $ echo 'EXTERN(__libc_start_main@@GLIBC_2.2.5)' > a.script $ g++ a.script a.script: file not recognized: File format not recognized collect2: error: ld returned 1 exit status To maintain compatibility with existing linker scripts support quoted strings in lld as well. Patch by Lucian Adrian Grijincu. Differential Revision: https://reviews.llvm.org/D57987 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@353756 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--ELF/ScriptParser.cpp2
-rw-r--r--test/ELF/linkerscript/linkerscript.s2
-rw-r--r--test/ELF/undefined-opt.s2
3 files changed, 3 insertions, 3 deletions
diff --git a/ELF/ScriptParser.cpp b/ELF/ScriptParser.cpp
index a33e92b07..a072b5a52 100644
--- a/ELF/ScriptParser.cpp
+++ b/ELF/ScriptParser.cpp
@@ -329,7 +329,7 @@ void ScriptParser::readEntry() {
void ScriptParser::readExtern() {
expect("(");
while (!errorCount() && !consume(")"))
- Config->Undefined.push_back(next());
+ Config->Undefined.push_back(unquote(next()));
}
void ScriptParser::readGroup() {
diff --git a/test/ELF/linkerscript/linkerscript.s b/test/ELF/linkerscript/linkerscript.s
index 39d2d4620..5e1cf27f0 100644
--- a/test/ELF/linkerscript/linkerscript.s
+++ b/test/ELF/linkerscript/linkerscript.s
@@ -3,7 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
# RUN: %p/Inputs/libsearch-st.s -o %t2.o
-# RUN: echo "EXTERN( undef undef2 )" > %t.script
+# RUN: echo "EXTERN( undef undef2 \"undef3\" \"undef4@@other\")" > %t.script
# RUN: ld.lld %t -o %t2 %t.script
# RUN: llvm-readobj %t2 > /dev/null
diff --git a/test/ELF/undefined-opt.s b/test/ELF/undefined-opt.s
index 9e93e0fdc..268995427 100644
--- a/test/ELF/undefined-opt.s
+++ b/test/ELF/undefined-opt.s
@@ -40,7 +40,7 @@
# TWO-UNDEFINED: Name: zed
# TWO-UNDEFINED: ]
# Now the same logic but linker script is used to set undefines
-# RUN: echo "EXTERN( bar abs )" > %t.script
+# RUN: echo "EXTERN( bar \"abs\" )" > %t.script
# RUN: ld.lld -o %t3 %t.o %tar.a %t.script
# RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=TWO-UNDEFINED %s