[lld] r278419 - Dead strip DESC bits should only be set on object files.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 14:27:18 PDT 2016


Author: pete
Date: Thu Aug 11 16:27:18 2016
New Revision: 278419

URL: http://llvm.org/viewvc/llvm-project?rev=278419&view=rev
Log:
Dead strip DESC bits should only be set on object files.

It only makes sense to set on N_NO_DEAD_STRIP on a relocatable object file.  Otherwise the bits aren't useful for anything.  Matches the ld64 behaviour.

Modified:
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
    lld/trunk/test/mach-o/dead-strip-globals.yaml

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp?rev=278419&r1=278418&r2=278419&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp Thu Aug 11 16:27:18 2016
@@ -963,7 +963,8 @@ uint16_t Util::descBits(const DefinedAto
     desc |= REFERENCED_DYNAMICALLY;
   if (_archHandler.isThumbFunction(*atom))
     desc |= N_ARM_THUMB_DEF;
-  if (atom->deadStrip() == DefinedAtom::deadStripNever) {
+  if (atom->deadStrip() == DefinedAtom::deadStripNever &&
+      _ctx.outputMachOType() == llvm::MachO::MH_OBJECT) {
     if ((atom->contentType() != DefinedAtom::typeInitializerPtr)
      && (atom->contentType() != DefinedAtom::typeTerminatorPtr))
     desc |= N_NO_DEAD_STRIP;

Modified: lld/trunk/test/mach-o/dead-strip-globals.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/dead-strip-globals.yaml?rev=278419&r1=278418&r2=278419&view=diff
==============================================================================
--- lld/trunk/test/mach-o/dead-strip-globals.yaml (original)
+++ lld/trunk/test/mach-o/dead-strip-globals.yaml Thu Aug 11 16:27:18 2016
@@ -2,6 +2,9 @@
 # RUN: lld -flavor darwin -arch x86_64 -export_dynamic -dead_strip %s -dylib %p/Inputs/x86_64/libSystem.yaml -o %t.dylib -print_atoms | FileCheck -check-prefix=CHECK1 %s
 # RUN: lld -flavor darwin -arch x86_64 -dead_strip %s -dylib %p/Inputs/x86_64/libSystem.yaml -o %t2.dylib -print_atoms | FileCheck -check-prefix=CHECK2 %s
 
+# RUN: lld -flavor darwin -arch x86_64 -r %s -dylib %p/Inputs/x86_64/libSystem.yaml -o %t3.o
+# RUN: llvm-nm -m %t3.o | FileCheck -check-prefix=RELOCATABLE_SYMBOLS %s
+
 #
 # Test that -export_dynamic -dead-strip from removing globals.
 #
@@ -25,3 +28,4 @@ shared-library-atoms:
 # CHECK2:       name: def
 # CHECK2-NOT:   name: dead
 
+# RELOCATABLE_SYMBOLS: external def




More information about the llvm-commits mailing list