GNU ld does not allow .foo : { (*foo) }, but we may recognize it as three
input section descriptions: file "(" with any section name, file "*foo" with
any section name, file ")" with any section name. Disallow the error-prone usage.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM. GNU ld documentation for InputSection https://sourceware.org/binutils/docs/ld/Input-Section-Basics.html states that An input section description consists of a file name optionally followed by a list of section names in parentheses. I couldn't find anything about which characters in filenames were not permitted. It looks like both lld and gnu ld can handle these when quoted. For example for a file "file(o)" we can write { "file(o)"(.text) } I do hope parentheses in filenames are not common though. Maybe worth a test case if we've not got one already.
Most printable characters are accepted in the filename pattern, with exception to ()#%. Seems that disallowing ( and )` is sufficient for us to disambiguate the grammar.
Parentheses in filenames are accepted if quoted. Let me check whether there is an existing test...