[PATCH] [lld] Add basic linker script parsing.
Michael Spencer
bigcheesegs at gmail.com
Wed Feb 27 23:42:14 PST 2013
================
Comment at: lib/ReaderWriter/LinkerScript.cpp:55
@@ +54,3 @@
+ switch (_buffer[0]) {
+ case 0:
+ tok = Token(_buffer.substr(0, 1), Token::eof);
----------------
Shankar Kalpathi Easwaran wrote:
> should this be \0 ?
>
> How about scripts having multiple lines of these ? Should that be handled too ?
>
> Might be good to raise an EOF only when you reached the eof while reading the file.
The MemoryBuffer API sticks a 0 at the end of the file. Since we only have text, 0 means end of file.
================
Comment at: lib/ReaderWriter/LinkerScript.cpp:69-70
@@ +68,4 @@
+ /// keyword or identifer.
+ StringRef::size_type end =
+ _buffer.find_first_of(" !@#$%^&*?><,~`\t\r\n()+={}[]\"':;\0");
+ if (end == StringRef::npos || end == 0) {
----------------
Shankar Kalpathi Easwaran wrote:
> Why these characters, !@#$%... ? The tokens can only be seperated only by spaces or tabs right ?
I wasn't sure and picked all punctuation. The docs don't say what characters are allowed. gold has special handling for / for file names, but only outside of parsing expressions.
For now I'll make whitespace be the only separator.
================
Comment at: lib/ReaderWriter/LinkerScript.cpp:101
@@ +100,3 @@
+ case '/':
+ if (_buffer.size() >= 2 && _buffer[1] == '*') {
+ // Skip starting /*
----------------
Shankar Kalpathi Easwaran wrote:
> It would be good to support // comments too ??
Not part of the language. However # line comments are. That can be added later.
================
Comment at: lib/ReaderWriter/LinkerScript.cpp:116-117
@@ +115,4 @@
+ }
+ } else
+ return;
+ break;
----------------
Shankar Kalpathi Easwaran wrote:
> should this return an error, if the comment is not formatted properly?
Probably, but that can be fixed later.
http://llvm-reviews.chandlerc.com/D477
More information about the llvm-commits
mailing list