We can support also EXCLUDE_FILE as top-level directive, but I'd rather do that in a separate patch.
Details
Diff Detail
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 | Maybe we should return std::vector<std::pair<StringRef, InputSectionDescription *>> instead. | |
99–100 | I'd pass InputSectionDescription * instead. | |
686 | 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 | if (skip("EXCLUDE_FILE")) { |
ELF/LinkerScript.cpp | ||
---|---|---|
687 | How about changing the return type of the function to InputSectionDescription * so that you don't need to pass OutputSectionCommand * to this function? | |
699 | KeptSections shouldn't be updated in this function because this function should be agnostic of the context. | |
712 | 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 | ||
---|---|---|
699 | So maybe we can pass an argument std::vector<StringRef> to collect the list of tokens and use that in readKeep() ? |
ELF/LinkerScript.cpp | ||
---|---|---|
699 | 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? |
Maybe we should return std::vector<std::pair<StringRef, InputSectionDescription *>> instead.