diff options
author | Pete Cooper <peter_cooper@apple.com> | 2016-08-11 21:27:18 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2016-08-11 21:27:18 +0000 |
commit | ef5bea9dca93b4b14f387fe8ad00d8798c0ab545 (patch) | |
tree | 8a3aed8215f2053fe0e63fe046678b12d932172e | |
parent | da2f38e0f48ca04a47157ccfe746330c7ee14a06 (diff) | |
download | bcm5719-llvm-ef5bea9dca93b4b14f387fe8ad00d8798c0ab545.tar.gz bcm5719-llvm-ef5bea9dca93b4b14f387fe8ad00d8798c0ab545.zip |
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.
llvm-svn: 278419
-rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp | 3 | ||||
-rw-r--r-- | lld/test/mach-o/dead-strip-globals.yaml | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index f315e2c6077..d8202c45cff 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -963,7 +963,8 @@ uint16_t Util::descBits(const DefinedAtom* atom) { 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; diff --git a/lld/test/mach-o/dead-strip-globals.yaml b/lld/test/mach-o/dead-strip-globals.yaml index 6cb8164106e..45d919db3aa 100644 --- a/lld/test/mach-o/dead-strip-globals.yaml +++ b/lld/test/mach-o/dead-strip-globals.yaml @@ -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 |