[PATCH] D22852: [ELF] - Linkerscript: implemented filename specification.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 14:46:48 PDT 2016


grimar added inline comments.

================
Comment at: ELF/LinkerScript.cpp:96
@@ +95,3 @@
+static bool fileMatches(const InputSectionDescription *Desc,
+                        StringRef FileName) {
+  if (!globMatch(Desc->FilePattern, FileName))
----------------
ruiu wrote:
> I think we used filename as one word in other places, so `Filename`.
Done.

================
Comment at: ELF/LinkerScript.cpp:109-111
@@ -102,3 +108,5 @@
   for (const std::unique_ptr<ObjectFile<ELFT>> &F :
-       Symtab<ELFT>::X->getObjectFiles())
+       Symtab<ELFT>::X->getObjectFiles()) {
+    if (!fileMatches(I, sys::path::filename(F->getName())))
+      continue;
     for (InputSectionBase<ELFT> *S : F->getSections())
----------------
ruiu wrote:
> Flip the condition and remove `continue`.
Done.

================
Comment at: ELF/LinkerScript.cpp:447
@@ -441,1 +446,3 @@
   std::vector<StringRef> readOutputSectionPhdrs();
+  void readInputSectionDescription(InputSectionDescription *InCmd);
+  void readInputSectionRules(InputSectionDescription *InCmd, bool Keep);
----------------
ruiu wrote:
> This looks weird. If this function reads an input section description, why do we have to pass an input section description to the function? If we can pass an input section description to the function, it implies that we have already read an input section description.
Fixed.

================
Comment at: ELF/LinkerScript.cpp:742-744
@@ -735,8 +741,5 @@
+    if ((!peek().empty() && peek()[0] == '*') || peek() == "KEEP") {
       auto *InCmd = new InputSectionDescription();
       Cmd->Commands.emplace_back(InCmd);
-      expect("(");
-      while (!Error && !skip(")"))
-        InCmd->Patterns.push_back(next());
-    } else if (Tok == "KEEP") {
-      readKeep(Cmd);
-    } else if (Tok == "PROVIDE") {
+      readInputSectionDescription(InCmd);
+      continue;
----------------
ruiu wrote:
> Huh, so you created an empty input section description and pass it to the function. You want to make readInputSectionDescription to return a new InputSectionDescription instead.
Done.


https://reviews.llvm.org/D22852





More information about the llvm-commits mailing list