[PATCH] D15767: [lld/ELF] Don't reclaim .ctors/.dtors

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 24 01:08:57 PST 2015


davide created this revision.
davide added reviewers: rafael, ruiu.
davide added a subscriber: llvm-commits.
Herald added a subscriber: emaste.

FreeBSD expects these to not be stripped even if not referenced to work. If they're not present/incomplete, the dynamic linker gets confused. This change allows lld/llvm/clang to self-host on FreeBSD/amd64. Looks like benchmarking season will start soon.

http://reviews.llvm.org/D15767

Files:
  ELF/MarkLive.cpp
  test/ELF/gc-sections.s

Index: test/ELF/gc-sections.s
===================================================================
--- test/ELF/gc-sections.s
+++ 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 @@
 y:
   call x
 
+.section .ctors,"aw", at progbits
+  .quad 0
+
+.section .dtors,"aw", at progbits
+  .quad 0
+
 .section .init,"aw", at init_array
   .quad 0
 
Index: ELF/MarkLive.cpp
===================================================================
--- ELF/MarkLive.cpp
+++ ELF/MarkLive.cpp
@@ -70,7 +70,8 @@
     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");
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15767.43588.patch
Type: text/x-patch
Size: 1326 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151224/ddb7ba72/attachment.bin>


More information about the llvm-commits mailing list