Fixes PR34948.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I think I like this. Few comments:
ELF/ScriptLexer.cpp | ||
---|---|---|
206 | What is this code for ? I tried following and no testcases failed for me: if (E == StringRef::npos) { assert(false); Ret.push_back(S); return Ret; } | |
231–232 | I think instead of passing function as argument it could probably be better to always call maybeSplit | |
ELF/ScriptLexer.h | ||
41 | Should this be single new enum variable ? |
ELF/ScriptParser.cpp | ||
---|---|---|
1342 | Actually, I think a better way of doing this is to pass two StringRefs, one for symbol name and the other for expression to this function. Introducing a different tokenization scheme only to separate "<sym>=<expr>" into <sym> and <expr> seems a bit too much. You probably should split a -defsym argument into two StringRefs in the driver. |
ELF/ScriptLexer.cpp | ||
---|---|---|
206 | It's the -defsym=foo case, I've added test case for this. | |
ELF/ScriptParser.cpp | ||
274 | I've changed this to use enum to represent the context. | |
1342 | That's what I've done in the first version: https://reviews.llvm.org/D39511?id=121190. Would you prefer that approach? The current approach is more akin to what gold and BFD.ld does. The main advantage of this approach is that the error messages that come out of script parser have the right offset, i.e. for -defsym=foo=bar, the error at offset 1 points to f while with the original approach it'd be b. |
ELF/ScriptParser.cpp | ||
---|---|---|
1342 | Yes, I think I prefer that over this patch. (A reason why you added defsym'ed symbols to the symbol table using addSymbolAlias in that patch isn't clear to me though.) |
ELF/ScriptParser.cpp | ||
---|---|---|
1342 | That was just a leftover code, that should be fixed now. |
LGTM
I think this is much better than the previous version.
ELF/Driver.cpp | ||
---|---|---|
1047–1048 | nit: you can eliminate by MB by readDefsym(From, MemoryBufferRef(To, "-defsym")). | |
ELF/ScriptParser.cpp | ||
274 | After this, you should call atEOF() to make sure that you've read all characters. Otherwise, I think you'll miss an error in `-defsym="(1+2)++++" for example, as readExpr will return at the closing parenthesis. |
nit: you can eliminate by MB by readDefsym(From, MemoryBufferRef(To, "-defsym")).