Index: ELF/MarkLive.cpp =================================================================== --- ELF/MarkLive.cpp +++ ELF/MarkLive.cpp @@ -183,7 +183,8 @@ if (isValidCIdentifier(S)) return true; - return S.startswith(".ctors") || S.startswith(".dtors") || + bool IsAllocSec = Sec->getSectionHdr()->sh_flags & SHF_ALLOC; + return !IsAllocSec || S.startswith(".ctors") || S.startswith(".dtors") || S.startswith(".init") || S.startswith(".fini") || S.startswith(".jcr"); } Index: test/ELF/gc-sections.s =================================================================== --- test/ELF/gc-sections.s +++ test/ELF/gc-sections.s @@ -14,6 +14,8 @@ # NOGC: Name: .dtors # NOGC: Name: .init # NOGC: Name: .fini +# NOGC: Name: .debug_pubtypes +# NOGC: Name: .comment # NOGC: Name: a # NOGC: Name: b # NOGC: Name: c @@ -100,3 +102,9 @@ .section .eh_frame,"a",@unwind .quad 0 + +.section .debug_pubtypes,"",@progbits + .quad 0 + +.section .comment,"MS",@progbits,8 + .quad 0