summaryrefslogtreecommitdiff
path: root/lld/ELF/MarkLive.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-11-30 14:01:06 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-11-30 14:01:06 +0000
commitc807ca8835c98a68b825b8e9107bcf19a7e9b300 (patch)
treeb8ddc21a4f7f243e36f8c3fb140c579edd4bbd0b /lld/ELF/MarkLive.cpp
parentf173ba9693c48a7825132766afb22d8b3d8a26c9 (diff)
[ELF] - Handle EhInputSection Live bit in MarkLive.cpp
Since MarkLive.cpp is the place where we set Live flags for other sections, it looks correct to do that there. Benefit is that we stop spreading GC logic outsize of MarkLive.cpp. Differential revision: https://reviews.llvm.org/D40454
Diffstat (limited to 'lld/ELF/MarkLive.cpp')
-rw-r--r--lld/ELF/MarkLive.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp
index e27d35c9a89..e2d2ee9c6cf 100644
--- a/lld/ELF/MarkLive.cpp
+++ b/lld/ELF/MarkLive.cpp
@@ -241,11 +241,15 @@ template <class ELFT> static void doGcSections() {
// Preserve special sections and those which are specified in linker
// script KEEP command.
for (InputSectionBase *Sec : InputSections) {
- // .eh_frame is always marked as live now, but also it can reference to
- // sections that contain personality. We preserve all non-text sections
- // referred by .eh_frame here.
- if (auto *EH = dyn_cast_or_null<EhInputSection>(Sec))
+ // Mark .eh_frame sections as live because there are usually no relocations
+ // that point to .eh_frames. Otherwise, the garbage collector would drop
+ // all of them. We also want to preserve personality routines and LSDA
+ // referenced by .eh_frame sections, so we scan them for that here.
+ if (auto *EH = dyn_cast_or_null<EhInputSection>(Sec)) {
+ EH->Live = true;
scanEhFrameSection<ELFT>(*EH, Enqueue);
+ }
+
if (Sec->Flags & SHF_LINK_ORDER)
continue;
if (isReserved<ELFT>(Sec) || Script->shouldKeep(Sec))