This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Linkerscript: reimplement readSectionExcludes()
ClosedPublic

Authored by grimar on Sep 19 2016, 7:59 AM.

Details

Summary

It is not only a bit more straightforward now, but also next 2 issues are solved:

  1. It just crashed on ".foo : { *(EXCLUDE_FILE (*file1.o)) }" before.
  2. It accepted multiple EXCLUDE_FILEs in a row.

Diff Detail

Event Timeline

grimar updated this revision to Diff 71822.Sep 19 2016, 7:59 AM
grimar retitled this revision from to [ELF] - Linkerscript: reimplement readSectionExcludes().
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.
ruiu added inline comments.Sep 19 2016, 4:43 PM
ELF/LinkerScript.cpp
-6–1

Move std::vector<StringRef> V just before this line to minimize the scope of the variable.

-6–1

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".

1

"section pattern is expected"

grimar updated this revision to Diff 71909.Sep 20 2016, 2:44 AM
  • Addressed review comments.
ELF/LinkerScript.cpp
-6–1

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.

grimar added inline comments.Sep 20 2016, 5:51 AM
ELF/LinkerScript.cpp
1074–1082

Next patch implements the syntax I am talking about: D24758

ruiu accepted this revision.Sep 20 2016, 9:27 PM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Sep 20 2016, 9:27 PM
This revision was automatically updated to reflect the committed changes.