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. | |
| 98–101 | I'd pass InputSectionDescription * instead. | |
| 669–670 | 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. | |
| 673–674 | if (skip("EXCLUDE_FILE")) { | |
| ELF/LinkerScript.cpp | ||
|---|---|---|
| 670 | How about changing the return type of the function to InputSectionDescription * so that you don't need to pass OutputSectionCommand * to this function? | |
| 673–679 | KeptSections shouldn't be updated in this function because this function should be agnostic of the context. | |
| 690 | 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 | ||
|---|---|---|
| 673–679 | So maybe we can pass an argument std::vector<StringRef> to collect the list of tokens and use that in readKeep() ? | |
| ELF/LinkerScript.cpp | ||
|---|---|---|
| 673–679 | 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.