[PATCH] D23768: [ELF] Linkerscript: eliminate LayoutInputSection

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 29 17:28:05 PDT 2016


ruiu added inline comments.

================
Comment at: ELF/InputSection.h:34-37
@@ +33,6 @@
+class InputSectionData {
+protected:
+  // If a section is compressed, this vector has uncompressed section data.
+  SmallVector<char, 0> Uncompressed;
+
+public:
----------------
Move this after `public` section.

================
Comment at: ELF/InputSection.h:46-48
@@ +45,5 @@
+  uint32_t Alignment;
+  // Used for garbage collection.
+  bool Live;
+  bool Compressed;
+};
----------------
Seems `Compressed` is also used by the garbage collector.

================
Comment at: ELF/InputSection.h:51-52
@@ -33,3 +50,4 @@
+
 // This corresponds to a section of an input file.
-template <class ELFT> class InputSectionBase {
+template <class ELFT> class InputSectionBase : public InputSectionData {
 protected:
----------------
Now the "Base" class has a base class? I seems to me that it's too object-oriented-ish, but let's see how it works.

================
Comment at: ELF/LinkerScript.cpp:212-213
@@ +211,4 @@
+        Ret.push_back(S);
+        S->OutSec = reinterpret_cast<OutputSectionBase<ELFT> *>(
+            std::numeric_limits<uintX_t>::max());
+      }
----------------
`reinterpret_cast<OutputSectionBase<ELFT> *>(-1ULL)`?

================
Comment at: ELF/LinkerScript.cpp:280
@@ -322,12 +279,3 @@
 
-  for (InputSection<ELFT> *I : OutSec->Sections) {
-    if (auto *L = dyn_cast<LayoutInputSection<ELFT>>(I)) {
-      uintX_t Value = L->Cmd->Expression(Sec->getVA() + Off) - Sec->getVA();
-      if (L->Cmd->Name == ".") {
-        Off = Value;
-      } else if (auto *Sym =
-                     cast_or_null<DefinedSynthetic<ELFT>>(L->Cmd->Sym)) {
-        // shouldDefine could have returned false, so we need to check Sym,
-        // for non-null value.
-        Sym->Section = OutSec;
-        Sym->Value = Value;
+  auto AddSuccessors = [&](InputSectionData *D) {
+    while (ItCmd != Cmd->Commands.end()) {
----------------
It needs a comment.


Repository:
  rL LLVM

https://reviews.llvm.org/D23768





More information about the llvm-commits mailing list