Commit Graph

7 Commits

Author SHA1 Message Date
Rui Ueyama b2f6fc177c Early continue. NFC.
llvm-svn: 252935
2015-11-12 19:45:58 +00:00
Rui Ueyama 92ce0e9122 ELF2: Make type a bit stricter. NFC.
llvm-svn: 252934
2015-11-12 19:42:43 +00:00
Rafael Espindola 8ea46e00f1 Start treating .eh_frame specially.
For now, just don't follow edges leaving from it to mark other sections
live.

llvm-svn: 252493
2015-11-09 17:44:10 +00:00
Rui Ueyama 12504649dc ELF2: Move some code from MarkLive.cpp to InputSection.cpp.
This function is useful for ICF, so move that to a common place.

llvm-svn: 251455
2015-10-27 21:51:13 +00:00
Rui Ueyama 2beabc9be5 ELF2: SymbolBody::repl() never returns a nullptr.
So we can use dyn_cast instead of dyn_cast_or_null here.

llvm-svn: 251076
2015-10-22 23:10:25 +00:00
Rui Ueyama 8a598f89ad ELF2: Keep .eh_frame even if they are not live.
.eh_frame sections need to be preserved if they refer to live sections.
So the liveness relation is reverse for eh_frame sections. For now,
we simply preserve all .eh_frame sections. Thanks Rafael for pointing
this out. .jcr are kept for the same reason.

llvm-svn: 251068
2015-10-22 21:42:05 +00:00
Rui Ueyama c4aaed9255 ELF2: Implement --gc-sections.
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 if you use
the feature because making sections means more work. 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

llvm-svn: 251043
2015-10-22 18:49:53 +00:00