[lld] 7c0881a - [ELF] --gc-sections: Change startwith(".jcr") to exact match

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 15 01:27:13 PST 2021


Author: Fangrui Song
Date: 2021-12-15T01:27:08-08:00
New Revision: 7c0881a38f5e0f50375a089e5a3c9b2d215be0e9

URL: https://github.com/llvm/llvm-project/commit/7c0881a38f5e0f50375a089e5a3c9b2d215be0e9
DIFF: https://github.com/llvm/llvm-project/commit/7c0881a38f5e0f50375a089e5a3c9b2d215be0e9.diff

LOG: [ELF] --gc-sections: Change startwith(".jcr") to exact match

GNU ld's internal linker script keeps `.jcr`, but not other sections
starting with `.jcr`.

Added: 
    

Modified: 
    lld/ELF/MarkLive.cpp
    lld/test/ELF/gc-sections.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp
index a040de09acb6..4a563f4eaef4 100644
--- a/lld/ELF/MarkLive.cpp
+++ b/lld/ELF/MarkLive.cpp
@@ -178,8 +178,8 @@ static bool isReserved(InputSectionBase *sec) {
     return !sec->nextInSectionGroup;
   default:
     StringRef s = sec->name;
-    return s == ".init" || s == ".fini" || s.startswith(".ctors") ||
-           s.startswith(".dtors") || s.startswith(".jcr");
+    return s == ".init" || s == ".fini" || s == ".jcr" ||
+           s.startswith(".ctors") || s.startswith(".dtors");
   }
 }
 

diff  --git a/lld/test/ELF/gc-sections.s b/lld/test/ELF/gc-sections.s
index 4e3dd5324f57..86dd6f64c4d2 100644
--- a/lld/test/ELF/gc-sections.s
+++ b/lld/test/ELF/gc-sections.s
@@ -17,6 +17,8 @@
 # NOGC: Name: .tbss
 # NOGC: Name: .ctors
 # NOGC: Name: .dtors
+# NOGC: Name: .jcr
+# NOGC: Name: .jcr_x
 # NOGC: Name: .debug_pubtypes
 # NOGC: Name: .comment
 # NOGC: Name: a
@@ -36,6 +38,7 @@
 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.tbss.f)
 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.tdata.h)
 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.init_x)
+# GC1-DISCARD-NEXT: removing unused section {{.*}}:(.jcr_x)
 # GC1-DISCARD-EMPTY:
 
 # GC1:     Name: .eh_frame
@@ -46,6 +49,7 @@
 # GC1:     Name: .tbss
 # GC1:     Name: .ctors
 # GC1:     Name: .dtors
+# GC1:     Name: .jcr
 # GC1:     Name: .debug_pubtypes
 # GC1:     Name: .comment
 # GC1:     Name: a
@@ -67,6 +71,7 @@
 # GC2:     Name: .tbss
 # GC2:     Name: .ctors
 # GC2:     Name: .dtors
+# GC2:     Name: .jcr
 # GC2:     Name: .debug_pubtypes
 # GC2:     Name: .comment
 # GC2:     Name: a
@@ -145,6 +150,12 @@ h:
 .section .preinit_array,"aw", at preinit_array
   .quad 0
 
+.section .jcr,"aw"
+  .quad 0
+
+.section .jcr_x,"aw"
+  .quad 0
+
 .section .eh_frame,"a", at unwind
   .quad 0
 


        


More information about the llvm-commits mailing list