summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/ScriptParser.cpp9
-rw-r--r--lld/test/ELF/version-script.s4
2 files changed, 11 insertions, 2 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 937b8a12e2f..4d8787b5edd 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -85,7 +85,7 @@ std::vector<StringRef> ScriptParserBase::tokenize(StringRef S) {
}
}
-// Skip leading whitespace characters or /**/-style comments.
+// Skip leading whitespace characters or comments.
StringRef ScriptParserBase::skipSpace(StringRef S) {
for (;;) {
if (S.startswith("/*")) {
@@ -97,6 +97,13 @@ StringRef ScriptParserBase::skipSpace(StringRef S) {
S = S.substr(E + 2);
continue;
}
+ if (S.startswith("#")) {
+ size_t E = S.find('\n', 1);
+ if (E == StringRef::npos)
+ E = S.size() - 1;
+ S = S.substr(E + 1);
+ continue;
+ }
size_t Size = S.size();
S = S.ltrim();
if (S.size() == Size)
diff --git a/lld/test/ELF/version-script.s b/lld/test/ELF/version-script.s
index 287800403a3..bbea4f45d46 100644
--- a/lld/test/ELF/version-script.s
+++ b/lld/test/ELF/version-script.s
@@ -8,7 +8,9 @@
# RUN: ld.lld --version-script %t.script -shared %t.o %t2.so -o %t.so
# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck --check-prefix=DSO %s
-# RUN: echo "{ local: *; };" > %t3.script
+# RUN: echo "# comment" > %t3.script
+# RUN: echo "{ local: *; # comment" >> %t3.script
+# RUN: echo -n "}; # comment" >> %t3.script
# RUN: ld.lld --version-script %t3.script -shared %t.o %t2.so -o %t3.so
# RUN: llvm-readobj -dyn-symbols %t3.so | FileCheck --check-prefix=DSO2 %s
OpenPOWER on IntegriCloud