The second SORT in *(SORT(...) SORT(...)) is incorrectly parsed as a file pattern.
Fix the bug by stopping at SORT* in readInputSectionsList.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Looks OK to me. Will be best to see if George has any comments about how to do the parsing.
lld/ELF/ScriptParser.cpp | ||
---|---|---|
651 | May be worth adding a SORT example here, as peek2() may look a bit strange without one. |
lld/ELF/ScriptParser.cpp | ||
---|---|---|
663 | I'd reformat the comment to have the sample on a single line, it is hard to read currently. // peek2() is used to detect "EXCLUDE_FILE(" or "SORT(" // (e.g. *(.foo SORT(.bar)) ) where we should break the loop. Also, our current grammar is LL(2), but we tried to use LL(1) where was possible. Our grammar of the linker script is LL(2), meaning that it needs at Given above I'd go with explicit version: while (!errorCount() && peek() != ")" && peek() != "SORT" && peek() != "EXCLUDE_FILE") Note:
# RUN: echo "SECTIONS { .abc : { *(SORT(.foo.*) .a* .a* SORT(.bar.*) FOO ( .b*) } }" > %t1.script
| |
lld/test/ELF/linkerscript/sort2.s | ||
8–10 | This is what is fixed by D91127, right? |
May be worth adding a SORT example here, as peek2() may look a bit strange without one.