[PATCH] D74687: [LLD][ELF] - Linker script: do not fail parsing when "/DISCARD/" follows the fill expression.
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 18 09:12:30 PST 2020
MaskRay added a comment.
In D74687#1880546 <https://reviews.llvm.org/D74687#1880546>, @grimar wrote:
> In D74687#1878409 <https://reviews.llvm.org/D74687#1878409>, @MaskRay wrote:
>
> > Do we have a more elegant fix:) ?
>
>
> Do you have something particular in mind? The only thing I can think of is to treat '\n' as an expression terminator.
> I am not sure it is a right thing to do. I think that `tokenizeExpr` used in this diff is a correct place for such fix.
> It has elegant name FWIW..
Treating `\n` as an expression terminator should work. For the following example, we will accept `a` but not `b` (GNU ld accepts both):
a = (3
+4);
b = 3
+4;
I prefer an alternative: limit `=` to accept `readPrimary` instead of `readFill`:
if (peek() == "=" || peek().startswith("=")) {
inExpr = true;
consume("=");
cmd->filler = readFill();
inExpr = false;
}
As you can see, GNU ld's `=` syntax is weird...
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74687/new/
https://reviews.llvm.org/D74687
More information about the llvm-commits
mailing list