[llvm] 5d7632e - MachO: don't emit L... private symbols in do_not_dead_strip sections.

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 15 06:40:54 PDT 2021


Author: Tim Northover
Date: 2021-07-15T14:40:43+01:00
New Revision: 5d7632ee72c51b518bde17e385b71c5d3f0d2560

URL: https://github.com/llvm/llvm-project/commit/5d7632ee72c51b518bde17e385b71c5d3f0d2560
DIFF: https://github.com/llvm/llvm-project/commit/5d7632ee72c51b518bde17e385b71c5d3f0d2560.diff

LOG: MachO: don't emit L... private symbols in do_not_dead_strip sections.

The linker can sometimes drop the do_not_dead_strip if it can't associate the
atom with a symbol (the other place to specify no dead-stripping in MachO
files).

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index ace475dbe86f9..56fdbc13a2bbf 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1480,11 +1480,10 @@ static bool canUsePrivateLabel(const MCAsmInfo &AsmInfo,
   if (!AsmInfo.isSectionAtomizableBySymbols(Section))
     return true;
 
-  // If it is not dead stripped, it is safe to use private labels.
-  const MCSectionMachO &SMO = cast<MCSectionMachO>(Section);
-  if (SMO.hasAttribute(MachO::S_ATTR_NO_DEAD_STRIP))
-    return true;
-
+  // FIXME: we should be able to use private labels for sections that can't be
+  // dead-stripped (there's no issue with blocking atomization there), but `ld
+  // -r` sometimes drops the no_dead_strip attribute from sections so for safety
+  // we don't allow it.
   return false;
 }
 

diff  --git a/llvm/test/CodeGen/X86/osx-private-labels.ll b/llvm/test/CodeGen/X86/osx-private-labels.ll
index d7f0251c1387a..ebc0a60e81dc1 100644
--- a/llvm/test/CodeGen/X86/osx-private-labels.ll
+++ b/llvm/test/CodeGen/X86/osx-private-labels.ll
@@ -73,7 +73,7 @@
 @private13 = private global i32 42, section "__DATA, __objc_classlist, regular, no_dead_strip"
 ; CHECK: .section	__DATA,__objc_classlist,regular,no_dead_strip
 ; CHECK-NEXT: .p2align	2
-; CHECK-NEXT: L_private13:
+; CHECK-NEXT: _private13:
 
 @private14 = private global [4 x i8] c"zed\00", section "__TEXT,__objc_classname,cstring_literals"
 ; CHECK: .section	__TEXT,__objc_classname,cstring_literals


        


More information about the llvm-commits mailing list