Allow L symbols in no_dead_strip sections.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 6 Nov 2014 02:42:03 +0000 (02:42 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 6 Nov 2014 02:42:03 +0000 (02:42 +0000)
If a section cannot be dead stripped, it is safe to use L symbols, since
the linker will keep all of it in the end.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221431 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetLoweringObjectFileImpl.cpp
test/CodeGen/X86/osx-private-labels.ll

index c7570ba76e125c2033e3b8b6a07e7f3ecd2019ad..6944f71105b701db34df967ebc2f4cb6c13923a8 100644 (file)
@@ -588,6 +588,10 @@ bool TargetLoweringObjectFileMachO::isSectionAtomizableBySymbols(
         SMO.getSectionName() == "__cfstring")
       return false;
 
+    // no_dead_strip sections are not atomized in practice.
+    if (SMO.hasAttribute(MachO::S_ATTR_NO_DEAD_STRIP))
+      return false;
+
     switch (SMO.getType()) {
     default:
       return true;
index 349ce7d0cc5e96438903d8b5a849cd014b66cae7..7e176442d2905585a4cb87751eb19f803c60b84a 100644 (file)
@@ -69,3 +69,8 @@
 ; CHECK: .section      __DATA,__foobar,interposing
 ; CHECK-NEXT: .align   3
 ; CHECK-NEXT: L_private12:
+
+@private13 = private global i32 42, section "__DATA, __objc_classlist, regular, no_dead_strip"
+; CHECK: .section      __DATA,__objc_classlist,regular,no_dead_strip
+; CHECK-NEXT: .align   2
+; CHECK-NEXT: L_private13: