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

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 10:30:31 PDT 2015


ruiu created this revision.
ruiu added a reviewer: rafael.
ruiu added a subscriber: llvm-commits.

Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.

In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.

This change has small negative impact on performance. The time to
link Clang changes from 0.356s to 0.386s, or +8%.

It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.


http://reviews.llvm.org/D13950

Files:
  ELF/CMakeLists.txt
  ELF/Config.h
  ELF/Driver.cpp
  ELF/InputFiles.cpp
  ELF/InputFiles.h
  ELF/InputSection.h
  ELF/MarkLive.cpp
  ELF/Options.td
  ELF/OutputSections.cpp
  ELF/SymbolTable.h
  ELF/Symbols.h
  ELF/Writer.cpp
  ELF/Writer.h
  test/elf2/gc-sections.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13950.38027.patch
Type: text/x-patch
Size: 14285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151021/ad50269a/attachment.bin>


More information about the llvm-commits mailing list