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

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 12:19:59 PDT 2016


ruiu added inline comments.

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

================
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())
----------------
Flip the condition and remove `continue`.

================
Comment at: ELF/LinkerScript.cpp:447
@@ -441,1 +446,3 @@
   std::vector<StringRef> readOutputSectionPhdrs();
+  void readInputSectionDescription(InputSectionDescription *InCmd);
+  void readInputSectionRules(InputSectionDescription *InCmd, bool Keep);
----------------
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.

================
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;
----------------
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.


https://reviews.llvm.org/D22852





More information about the llvm-commits mailing list