[PATCH] D13950: ELF2: Implement --gc-sections.

Rafael Ávila de Espíndola via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 15:12:22 PDT 2015


rafael added inline comments.

================
Comment at: ELF/MarkLive.cpp:67
@@ +66,3 @@
+static bool isReserved(StringRef S) {
+  return S.startswith(".ctors") || S.startswith(".dtors") ||
+         S.startswith(".fini") || S.startswith(".init") ||
----------------
Can you check anything other than the name? The section type or flags maybe?

================
Comment at: ELF/MarkLive.cpp:95
@@ +94,3 @@
+
+  // Preserve externally-visible symbols.
+  for (const std::pair<StringRef, Symbol *> &P : Symtab->getSymbols()) {
----------------
]You only need to do this if you are producing a shared library or --export-dynamic is used.

================
Comment at: ELF/Writer.cpp:425
@@ -424,3 +424,3 @@
     for (InputSectionBase<ELFT> *C : F->getSections()) {
-      if (!C || C == &InputSection<ELFT>::Discarded)
+      if (!C || !C->isLive() || C == &InputSection<ELFT>::Discarded)
         continue;
----------------
Can you check for "this == &InputSection<ELFT>::Discarded" in isLive?


http://reviews.llvm.org/D13950





More information about the llvm-commits mailing list