[PATCH] D38996: [ELF] - Simplify how GC works with MergeInputSection.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 19 04:53:21 PDT 2017


grimar added inline comments.


================
Comment at: ELF/InputSection.h:275
+  bool arePiecesLiveByDefault() {
+    return !Config->GcSections || !(this->Flags & llvm::ELF::SHF_ALLOC);
+  }
----------------
ruiu wrote:
> Why don't you garbage-collect non-allocated strings?
Honestly not sure I got the question right, because my patch does not change this logic and
we do that really long time (if not from begining).

Reason behind not-collecting non-allocated string sections I believe is following. Usually
such sections are debug ones. For example .debug_str section is non-allocatable and contains
strings(It has "MS" flags normally).

We can apply string merging optimization to such section, but we should not collect it.
.debug_info section has references to .debug_str via DW_FORM_strp, so it
has relocation that calculates an offset in .debug_str. .
.debug_info itself is also debug non-allocatable section
which should not be collected, otherwise we would lose all debug information.
And there is nothing else that can keep .debug_str alive as there are normally no references to .debug_str from
allocatable sections I think. Does this answer your question ?


https://reviews.llvm.org/D38996





More information about the llvm-commits mailing list