We can support also EXCLUDE_FILE as top-level directive, but I'd rather do that in a separate patch.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Sorry, I updated a stale version of the tests. I'll update a new version of the tests soon.
ELF/LinkerScript.cpp | ||
---|---|---|
82 ↗ | (On Diff #65461) | Maybe we should return std::vector<std::pair<StringRef, InputSectionDescription *>> instead. |
99–100 ↗ | (On Diff #65461) | I'd pass InputSectionDescription * instead. |
686 ↗ | (On Diff #65461) | The grammar of KEEP is KEEP := "KEEP" "(" FILE_PATTERN ")" FILE_PATTERN := GLOB+ "(" "EXCLUDE_FILE" "(" GLOB+ ")" GLOB+ ")" | GLOB+ "(" GLOB+ ")" GLOB+ ")" where GLOB is any glob pattern. FILE_PATTERN is the same as one of the SECTIONS subcommands. So I think you want to define readFilePattern and use it both from this function and from readOutputSectionDescription. |
694–695 ↗ | (On Diff #65461) | if (skip("EXCLUDE_FILE")) { |
ELF/LinkerScript.cpp | ||
---|---|---|
670 ↗ | (On Diff #65637) | How about changing the return type of the function to InputSectionDescription * so that you don't need to pass OutputSectionCommand * to this function? |
681 ↗ | (On Diff #65637) | KeptSections shouldn't be updated in this function because this function should be agnostic of the context. |
694 ↗ | (On Diff #65637) | If you change the return type, then you can write InputSectionCommand *InCmd = readFilePattern(); Opt.KeptSections.insert(Opt.KeptSections.end(), InCmd.Patterns.begin(), InCmd.Patterns.end()); Cmd.emplace_back(InCmd); |
ELF/LinkerScript.cpp | ||
---|---|---|
681 ↗ | (On Diff #65637) | So maybe we can pass an argument std::vector<StringRef> to collect the list of tokens and use that in readKeep() ? |
ELF/LinkerScript.cpp | ||
---|---|---|
681 ↗ | (On Diff #65637) | File pattern consists of file names followed by section names, so std::vector<StringRef> is not enough because it is unstructured. Did you read my comment at line 694? Didn't it work? |
LGTM with a nit.
ELF/LinkerScript.cpp | ||
---|---|---|
694 ↗ | (On Diff #65641) | push_back(std::move(InCmd)) |
excessive space at the end