[lld] r260185 - We should never dead strip mach header symbols.
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 8 17:34:13 PST 2016
Author: pete
Date: Mon Feb 8 19:34:13 2016
New Revision: 260185
URL: http://llvm.org/viewvc/llvm-project?rev=260185&view=rev
Log:
We should never dead strip mach header symbols.
This was a bug in our handling of these symbols compared to ld64.
Turns out that ld64 always marks these symbols as being not dead stripped.
Modified:
lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.h
lld/trunk/test/mach-o/mh_bundle_header.yaml
Modified: lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.h?rev=260185&r1=260184&r2=260185&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.h Mon Feb 8 19:34:13 2016
@@ -71,7 +71,6 @@ public:
: SimpleFile("mach_header symbols", kindHeaderObject) {
StringRef machHeaderSymbolName;
DefinedAtom::Scope symbolScope = DefinedAtom::scopeLinkageUnit;
- bool noDeadStrip = false;
StringRef dsoHandleName;
switch (context.outputMachOType()) {
case llvm::MachO::MH_OBJECT:
@@ -80,7 +79,6 @@ public:
case llvm::MachO::MH_EXECUTE:
machHeaderSymbolName = "__mh_execute_header";
symbolScope = DefinedAtom::scopeGlobal;
- noDeadStrip = true;
dsoHandleName = "___dso_handle";
break;
case llvm::MachO::MH_FVMLIB:
@@ -112,13 +110,15 @@ public:
if (!machHeaderSymbolName.empty())
_definedAtoms.push_back(new (allocator()) MachODefinedAtom(
*this, machHeaderSymbolName, symbolScope,
- DefinedAtom::typeMachHeader, DefinedAtom::mergeNo, false, noDeadStrip,
+ DefinedAtom::typeMachHeader, DefinedAtom::mergeNo, false,
+ true /* noDeadStrip */,
ArrayRef<uint8_t>(), DefinedAtom::Alignment(4096)));
if (!dsoHandleName.empty())
_definedAtoms.push_back(new (allocator()) MachODefinedAtom(
*this, dsoHandleName, DefinedAtom::scopeLinkageUnit,
- DefinedAtom::typeDSOHandle, DefinedAtom::mergeNo, false, false,
+ DefinedAtom::typeDSOHandle, DefinedAtom::mergeNo, false,
+ true /* noDeadStrip */,
ArrayRef<uint8_t>(), DefinedAtom::Alignment(1)));
}
Modified: lld/trunk/test/mach-o/mh_bundle_header.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/mh_bundle_header.yaml?rev=260185&r1=260184&r2=260185&view=diff
==============================================================================
--- lld/trunk/test/mach-o/mh_bundle_header.yaml (original)
+++ lld/trunk/test/mach-o/mh_bundle_header.yaml Mon Feb 8 19:34:13 2016
@@ -1,5 +1,5 @@
-# RUN: lld -flavor darwin -arch x86_64 %s -bundle -o %t %p/Inputs/libSystem.yaml
-# RUN: llvm-nm -m -n %t | FileCheck %s
+# RUN: lld -flavor darwin -arch x86_64 %s -bundle -o %t %p/Inputs/libSystem.yaml && llvm-nm -m -n %t | FileCheck %s
+# RUN: lld -flavor darwin -arch x86_64 %s -bundle -dead_strip -o %t %p/Inputs/libSystem.yaml && llvm-nm -m -n %t | FileCheck %s
#
# Test that __mh_bundle_header symbol is available for bundles
#
@@ -39,6 +39,7 @@ global-symbols:
type: N_SECT
scope: [ N_EXT ]
sect: 1
+ desc: [ N_NO_DEAD_STRIP ]
value: 0x0000000000000000
undefined-symbols:
- name: __mh_bundle_header
@@ -49,5 +50,5 @@ undefined-symbols:
...
-# CHECK_NOT: __mh_bundle_header
+# CHECK: __mh_bundle_header
# CHECK: _foo
More information about the llvm-commits
mailing list