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.
This commit is contained in:
parent
7809e04e3c
commit
b00c8ab1b9
|
@ -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") ||
|
||||
|
|
|
@ -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",@init_array,aaa
|
||||
.byte 0
|
||||
|
||||
.section .mybss.aaa,"awG",@nobits,aaa
|
||||
bss_aaa:
|
||||
.byte 0
|
||||
|
|
Loading…
Reference in New Issue