[PATCH] D13703: [ELF2/Linkerscript] Skip semicolon in linker directives parsing
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 13 11:33:42 PDT 2015
davide created this revision.
davide added reviewers: ruiu, rafael.
davide added a subscriber: llvm-commits.
davide set the repository for this revision to rL LLVM.
According to docs, semicolons are mandatory at the end of assignment but they're allowed/optional in directives. I found an example of that in a FreeBSD linker script. I'll change the linker script in FreeBSD to remove the semicolon but I think it's good we support this for GNU ld compatibility.
Repository:
rL LLVM
http://reviews.llvm.org/D13703
Files:
ELF/LinkerScript.cpp
test/elf2/linkerscript.s
Index: test/elf2/linkerscript.s
===================================================================
--- test/elf2/linkerscript.s
+++ test/elf2/linkerscript.s
@@ -76,6 +76,14 @@
# RUN: ld.lld2 %t.script %t
# RUN: llvm-readobj %t.out > /dev/null
+# RUN: echo ";SEARCH_DIR(x);SEARCH_DIR(y);" > %t.script
+# RUN: ld.lld2 %t.script %t
+# RUN: llvm-readobj %t.out > /dev/null
+
+# RUN: echo ";" > %t.script
+# RUN: ld.lld2 %t.script %t
+# RUN: llvm-readobj %t.out > /dev/null
+
# RUN: echo "INCLUDE " %t.script2 "OUTPUT(" %t.out ")" > %t.script1
# RUN: echo "GROUP(" %t ")" > %t.script2
# RUN: ld.lld2 %t.script1
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -59,7 +59,10 @@
void LinkerScript::run() {
while (!atEOF()) {
StringRef Tok = next();
- if (Tok == "ENTRY") {
+ if (Tok == ";") {
+ continue;
+ }
+ else if (Tok == "ENTRY") {
readEntry();
} else if (Tok == "GROUP" || Tok == "INPUT") {
readGroup();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13703.37277.patch
Type: text/x-patch
Size: 1056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151013/99cb3f8d/attachment.bin>
More information about the llvm-commits
mailing list