summaryrefslogtreecommitdiff
path: root/lld/ELF/MarkLive.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-10-24 08:26:32 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-10-24 08:26:32 +0000
commit9ba8e1b14283c604e1873b98ffb0c1ebe8311b0d (patch)
treeee3bff1538d960917de4ee397963b45ae1445bf6 /lld/ELF/MarkLive.cpp
parente3877815f449531ebebca46bd8767768148cc67e (diff)
[ELF] - Do not collect SHT_REL[A] sections unconditionally when --gc-sections and --emit-relocs used together.
This is "Bug 34836 - --gc-sections remove relocations from --emit-relocs", When --emit-relocs is used, LLD currently always drops SHT_REL[A] sections from output if --gc-sections is present. Patch fixes the issue. Differential revision: https://reviews.llvm.org/D38724
Diffstat (limited to 'lld/ELF/MarkLive.cpp')
-rw-r--r--lld/ELF/MarkLive.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp
index 62a0039ef01..05fe3a494c7 100644
--- a/lld/ELF/MarkLive.cpp
+++ b/lld/ELF/MarkLive.cpp
@@ -162,9 +162,9 @@ scanEhFrameSection(EhInputSection &EH,
scanEhFrameSection<ELFT>(EH, EH.template rels<ELFT>(), Fn);
}
-// We do not garbage-collect two types of sections:
-// 1) Sections used by the loader (.init, .fini, .ctors, .dtors or .jcr)
-// 2) Non-allocatable sections which typically contain debugging information
+// Some sections are used directly by the loader, so they should never be
+// garbage-collected. This function returns true if a given section is such
+// section.
template <class ELFT> static bool isReserved(InputSectionBase *Sec) {
switch (Sec->Type) {
case SHT_FINI_ARRAY:
@@ -173,9 +173,6 @@ template <class ELFT> static bool isReserved(InputSectionBase *Sec) {
case SHT_PREINIT_ARRAY:
return true;
default:
- if (!(Sec->Flags & SHF_ALLOC))
- return true;
-
StringRef S = Sec->Name;
return S.startswith(".ctors") || S.startswith(".dtors") ||
S.startswith(".init") || S.startswith(".fini") ||
@@ -198,9 +195,6 @@ template <class ELFT> static void doGcSections() {
if (Sec == &InputSection::Discarded)
return;
- // We don't gc non alloc sections.
- if (!(Sec->Flags & SHF_ALLOC))
- return;
// Usually, a whole section is marked as live or dead, but in mergeable
// (splittable) sections, each piece of data has independent liveness bit.