[PATCH] D22749: [ELF] - Linkerscript: Implemented SORT command

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 15:15:29 PDT 2016


ruiu added inline comments.

================
Comment at: ELF/LinkerScript.cpp:113-123
@@ +112,13 @@
+// then create it and add to output section list.
+template <class ELFT>
+static void addSection(OutputSectionFactory<ELFT> &Factory,
+                       std::vector<OutputSectionBase<ELFT> *> &Out,
+                       InputSectionBase<ELFT> *C, StringRef Name) {
+  OutputSectionBase<ELFT> *Sec;
+  bool IsNew;
+  std::tie(Sec, IsNew) = Factory.create(C, Name);
+  if (IsNew)
+    Out.push_back(Sec);
+  Sec->addSection(C);
+}
+
----------------
This change makes me wonder why we need the Factory in the linker script. We need to create output sections as instructed by linker scripts. But, the factory may create different output sections with the same name. I started to think that this is not correct.

================
Comment at: ELF/LinkerScript.h:137
@@ -135,3 +136,3 @@
 private:
-  std::vector<std::pair<StringRef, const InputSectionDescription *>>
+  std::vector<std::pair<StringRef, std::vector<const BaseCommand *>>>
   getSectionMap();
----------------
ArrayRef?


https://reviews.llvm.org/D22749





More information about the llvm-commits mailing list