This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ELF] - Linkerscript: Fix FILL() expressions handling.
ClosedPublic

Authored by grimar on Jul 10 2019, 5:05 AM.

Details

Summary

D64130 introduced a bug described in the following message:
https://reviews.llvm.org/D64130#1571560

The problem can happen with the following script:

SECTIONS {
  .out : {
...
   FILL(0x10101010)
   *(.aaa)
...
}

The current code tries to read (0x10101010) as an expression and
does not break when meets *, what results in a script parsing error.

In this patch, I verify that FILL command's expression always wrapped in ().
And at the same time =<fillexp> expression can be both wrapped or unwrapped.
I checked it matches to bfd/gold.

Diff Detail

Event Timeline

grimar created this revision.Jul 10 2019, 5:05 AM
MaskRay accepted this revision.Jul 10 2019, 5:54 AM
MaskRay added inline comments.
ELF/ScriptParser.cpp
887

This function doesn't need any change. expect("(") below should be sufficient.

readParenExpr will handle the parenthesized expression.

This revision is now accepted and ready to land.Jul 10 2019, 5:54 AM
grimar marked 2 inline comments as done.Jul 10 2019, 7:32 AM
grimar added inline comments.
ELF/ScriptParser.cpp
887

Hmm. Right. Not sure why I did that.

This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2019, 7:37 AM