[PATCH] D24726: [ELF] - Linkerscript: reimplement readSectionExcludes()

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 02:44:45 PDT 2016


grimar added inline comments.

================
Comment at: ELF/LinkerScript.cpp:1081
@@ -1094,2 +1080,3 @@
 
-    V.push_back(next());
+    while (!Error && peek() != ")" && peek() != "EXCLUDE_FILE")
+      V.push_back(next());
----------------
ruiu wrote:
> ruiu wrote:
> > Move `std::vector<StringRef> V` just before this line to minimize the scope of the variable.
> Checking for `EXCLUDE_FILE` here seems too arbitrary. What if it is other reserved word such as SORT? I think we don't want to handle EXCLUDE_FILE as a special case. I'd remove `&& peek() == "EXCLUDE_FILE"`.
I do not think it is possible to meet other keywords, about SORT:
there is a difference in semanics of ld/gold.

ld wants:
```
 *(SORT(EXCLUDE_FILE (*file1.o) .foo.1))
```

Example of valid syntax:
```
SECTIONS {
foo : {
*(SORT(EXCLUDE_FILE (*file1.o) .foo.1)  .foo.3 EXCLUDE_FILE (*file1.o) .foo.1)
}
};
```

gold likes different order.
```
 *(EXCLUDE_FILE (*file1.o) SORT(.foo.1))
```
Example of valid syntax:

```
SECTIONS {
foo : {
*(EXCLUDE_FILE (*file1.o) SORT(.foo.1) EXCLUDE_FILE (*file1.o) .foo.2)
}
};

```

I am inclined to think that means that in real world excludes probably not used with sorting. But anyways we probably should choose which semantic to support. I suggest to go with ld way: list of sections with file excludes is a subject/argument for SORT that is outside.

So basing on above, function is named readSectionExcludes(), it is about next list:
((EXCLUDE_FILE(file_pattern+))? section_pattern+)+
So it is should not be possible to meet any other key word I think and I still need that check, because if I see new "EXCLUDE_FILE" that means I need to start new [ExcludeFile, SectionsRegex] entry here.






https://reviews.llvm.org/D24726





More information about the llvm-commits mailing list