[PATCH] D74687: [LLD][ELF] - Linker script: do not fail parsing when "/DISCARD/" follows the fill expression.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 03:06:07 PST 2020
grimar added a comment.
In D74687#1880879 <https://reviews.llvm.org/D74687#1880879>, @MaskRay wrote:
> I prefer an alternative: limit `=` to accept `readPrimary` instead of `readFill`:
>
> if (peek() == "=" || peek().startswith("=")) {
> inExpr = true;
> consume("=");
> cmd->filler = readFill();
> inExpr = false;
> }
>
>
>
Honestly I just do not feel comfortable to do this change.
If I currectly understood, you're suggesting something like:
if (peek() == "=" || peek().startswith("=")) {
inExpr = true;
consume("=");
uint64_t value = readPrimary()().val;
std::array<uint8_t, 4> buf;
write32be(buf.data(), (uint32_t)value);
cmd->filler = buf;
inExpr = false;
}
With it we stop supporting syntax like `SECTIONS { .mysec : { *(.mysec*) } =0x11223300+0x44 }`.
It is a deviation from the specification which says that "fillexp is an expression" and mentions a unary +.
> As you can see, GNU ld's `=` syntax is weird...
Yes, but it the current state LLD seems to have a reasonable behavior.
I am not sure we should intentionally ignore specification and remove this feature just because of a specific issue
with "/DISCARD/".
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74687/new/
https://reviews.llvm.org/D74687
More information about the llvm-commits
mailing list