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

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 15:18:45 PDT 2015


ruiu 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") ||
----------------
rafael wrote:
> Can you check anything other than the name? The section type or flags maybe?
This list may be limited but I don't know what other sections need to be preserved.

gold seems to preserve more sections (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gold/object.cc;h=76d4630d16a8cfbe445f421250798c3438aa48e4;hb=HEAD#l353). I didn't copy that as I don't know the rational for some sections listed there.

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


http://reviews.llvm.org/D13950





More information about the llvm-commits mailing list