[PATCH] D24758: [ELF] - Linkerscript: support complex section pattern grammar.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 21 08:06:05 PDT 2016


ruiu added inline comments.

================
Comment at: ELF/LinkerScript.cpp:774-775
@@ -770,2 +773,4 @@
   Regex readFilePatterns();
-  void readSectionExcludes(InputSectionDescription *Cmd);
+  std::vector<SectionPattern> readInputSectionsList(SortSectionPolicy SortOut,
+                                                    SortSectionPolicy SortIn);
+  std::vector<SectionPattern>
----------------
Out and In look like they are short for Output and Input, so these names are confusing. Since we know the type here, Inner and Outer should suffice.

================
Comment at: ELF/LinkerScript.cpp:1133-1137
@@ -1099,1 +1132,7 @@
+    SortSectionPolicy SortOut = readSortKind();
+    if (SortOut != SortSectionPolicy::Default)
+      V = readSortedInputSectionsList(SortOut);
+    else
+      V = readInputSectionsList(SortSectionPolicy::Default,
+                                SortSectionPolicy::Default);
 
----------------
This code seem too complicated compared to what it is doing. I think you could do like this.

  SortSectionPolicy Inner = readSortKind();
  SortSectionPolicy Outer = Default;
  if (Inner != SortSectionPolicy::Default) {
    expect("(");
    Outer = readSortKind();
    if (Outer != SortSectionPolicy::Default) {
      expect("(");
      V = readInputSectionList();
      expect(")");
    } else {
      V = readInputSectionList();
    }
    expect(")");
  }

  for (SectionPattern &Pat : V) {
    Pat.SortInner = Inner;
    Pat.SortOuter = Outer;
  }



https://reviews.llvm.org/D24758





More information about the llvm-commits mailing list