[PATCH] D27040: [ELF] - Add support for access to most of synthetic sections from linkerscript.

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 23 05:31:55 PST 2016


evgeny777 added inline comments.


================
Comment at: ELF/Writer.cpp:230
+  Symtab<ELFT>::X->Sections.push_back(Targ);
+};
+
----------------
This looks better

```
auto add = [](InputSection<ELFT> *IS) {
  Symtab<ELFT>::X->Sections.push_back(IS);
  return IS;
};
```



================
Comment at: ELF/Writer.cpp:255
+  if (needsInterpSection<ELFT>())
+    doAdd<ELFT>(In<ELFT>::Interp, createInterpSection<ELFT>());
+  else
----------------
```
In<ELFT>::Interp = add(createInterpSection<ELFT>());
```


================
Comment at: ELF/Writer.cpp:723
   for (InputSectionBase<ELFT> *IS : Symtab<ELFT>::X->Sections) {
-    if (!IS->Live)
+    if (!IS || !IS->Live)
       continue;
----------------
Why are you checking IS for nullptr?


================
Comment at: ELF/Writer.cpp:883
+    SyntheticSection<ELFT> *SS = dyn_cast<SyntheticSection<ELFT>>(*I);
+    if (!SS)
+      return;
----------------
Why are you checking for null?


================
Comment at: ELF/Writer.cpp:889
+    OutputSection<ELFT> *OutSec = cast<OutputSection<ELFT>>(SS->OutSec);
+    OutSec->Sections.erase(
+        std::find(OutSec->Sections.begin(), OutSec->Sections.end(), SS),
----------------
Looks like you're removing all sections starting from unused synthetic till the end of the input section array. May be you actually wanted to use std::remove() ?


https://reviews.llvm.org/D27040





More information about the llvm-commits mailing list