[lld] b00c8ab - Revert "[ELF] --gc-sections: allow GC on reserved sections in a group"
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 27 16:34:39 PDT 2021
Author: Fangrui Song
Date: 2021-07-27T16:34:32-07:00
New Revision: b00c8ab1b915d7f32ad7a60255f33f210e12a3c6
URL: https://github.com/llvm/llvm-project/commit/b00c8ab1b915d7f32ad7a60255f33f210e12a3c6
DIFF: https://github.com/llvm/llvm-project/commit/b00c8ab1b915d7f32ad7a60255f33f210e12a3c6.diff
LOG: Revert "[ELF] --gc-sections: allow GC on reserved sections in a group"
clang may place dynamic initializations for explicitly specialized class
template static data members in comdat.
Such in-comdat SHT_INIT_ARRAY was an abuse but we have to work around it for a while.
Added:
Modified:
lld/ELF/MarkLive.cpp
lld/test/ELF/gc-sections-group.s
Removed:
################################################################################
diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp
index 0378a19e1919d..e828429b421c3 100644
--- a/lld/ELF/MarkLive.cpp
+++ b/lld/ELF/MarkLive.cpp
@@ -168,15 +168,14 @@ void MarkLive<ELFT>::scanEhFrameSection(EhInputSection &eh,
// garbage-collected. This function returns true if a given section is such
// section.
static bool isReserved(InputSectionBase *sec) {
- if (sec->nextInSectionGroup)
- return false;
-
switch (sec->type) {
case SHT_FINI_ARRAY:
case SHT_INIT_ARRAY:
case SHT_PREINIT_ARRAY:
- case SHT_NOTE:
return true;
+ case SHT_NOTE:
+ // SHT_NOTE sections in a group are subject to garbage collection.
+ return !sec->nextInSectionGroup;
default:
StringRef s = sec->name;
return s.startswith(".ctors") || s.startswith(".dtors") ||
diff --git a/lld/test/ELF/gc-sections-group.s b/lld/test/ELF/gc-sections-group.s
index 0b74f6fa707ea..da4cad98f3653 100644
--- a/lld/test/ELF/gc-sections-group.s
+++ b/lld/test/ELF/gc-sections-group.s
@@ -10,7 +10,6 @@
## .mynote.ccc is retained because it is not in a group.
# CHECK-DEAD-NOT: Name: .myanote.aaa
# CHECK-DEAD-NOT: Name: .mytext.aaa
-# CHECK-DEAD-NOT: Name: .myinit_array.aaa
# CHECK-DEAD-NOT: Name: .mybss.aaa
# CHECK-DEAD-NOT: Name: .mynote.aaa
# CHECK-DEAD-NOT: Name: .myanote.bbb
@@ -33,7 +32,6 @@
# CHECK-LIVE-GROUP: Name: .myanote.aaa
# CHECK-LIVE-GROUP: Name: .mytext.aaa
-# CHECK-LIVE-GROUP: Name: .myinit_array.aaa
# CHECK-LIVE-GROUP: Name: .mybss.aaa
# CHECK-LIVE-GROUP: Name: .mynote.aaa
# CHECK-LIVE-GROUP-NOT: Name: .myanote.bbb
@@ -56,7 +54,6 @@
# CHECK-LIVE-COMDAT-NOT: Name: .myanote.aaa
# CHECK-LIVE-COMDAT-NOT: Name: .mytext.aaa
-# CHECK-LIVE-COMDAT-NOT: Name: .myinit_array.aaa
# CHECK-LIVE-COMDAT-NOT: Name: .mybss.aaa
# CHECK-LIVE-COMDAT-NOT: Name: .mynote.aaa
# CHECK-LIVE-COMDAT: Name: .myanote.bbb
@@ -76,9 +73,6 @@ anote_aaa:
aaa:
.byte 0
-.section .myinit_array.aaa,"awG", at init_array,aaa
-.byte 0
-
.section .mybss.aaa,"awG", at nobits,aaa
bss_aaa:
.byte 0
More information about the llvm-commits
mailing list