diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index 5e6cb639787e..c44220a981a9 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -70,7 +70,8 @@ template static bool isReserved(InputSectionBase *Sec) { return true; default: StringRef S = Sec->getSectionName(); - return S.startswith(".init") || S.startswith(".fini") || + return S.startswith(".ctors") || S.startswith(".dtors") || + S.startswith(".init") || S.startswith(".fini") || S.startswith(".jcr"); } } diff --git a/lld/test/ELF/gc-sections.s b/lld/test/ELF/gc-sections.s index 5c27ad77f58c..93f7dc67023f 100644 --- a/lld/test/ELF/gc-sections.s +++ b/lld/test/ELF/gc-sections.s @@ -10,6 +10,8 @@ # NOGC: Name: .eh_frame # NOGC: Name: .text +# NOGC: Name: .ctors +# NOGC: Name: .dtors # NOGC: Name: .init # NOGC: Name: .fini # NOGC: Name: a @@ -23,6 +25,8 @@ # GC1: Name: .eh_frame # GC1: Name: .text +# GC1: Name: .ctors +# GC1: Name: .dtors # GC1: Name: .init # GC1: Name: .fini # GC1: Name: a @@ -36,6 +40,8 @@ # GC2: Name: .eh_frame # GC2: Name: .text +# GC2: Name: .ctors +# GC2: Name: .dtors # GC2: Name: .init # GC2: Name: .fini # GC2: Name: a @@ -77,6 +83,12 @@ x: y: call x +.section .ctors,"aw",@progbits + .quad 0 + +.section .dtors,"aw",@progbits + .quad 0 + .section .init,"aw",@init_array .quad 0