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.

llvm-svn: 260185
This commit is contained in:
Pete Cooper 2016-02-09 01:34:13 +00:00
parent cea565593f
commit 841a978d22
2 changed files with 8 additions and 7 deletions

View File

@ -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)));
}

View File

@ -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