MachHeaderAliasFile(const MachOLinkingContext &context)
: 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:
break;
case llvm::MachO::MH_EXECUTE:
machHeaderSymbolName = "__mh_execute_header";
+ symbolScope = DefinedAtom::scopeGlobal;
+ noDeadStrip = true;
dsoHandleName = "___dso_handle";
break;
case llvm::MachO::MH_FVMLIB:
}
if (!machHeaderSymbolName.empty())
_definedAtoms.push_back(new (allocator()) MachODefinedAtom(
- *this, machHeaderSymbolName, DefinedAtom::scopeLinkageUnit,
- DefinedAtom::typeMachHeader, DefinedAtom::mergeNo, false, false,
+ *this, machHeaderSymbolName, symbolScope,
+ DefinedAtom::typeMachHeader, DefinedAtom::mergeNo, false, noDeadStrip,
ArrayRef<uint8_t>(), DefinedAtom::Alignment(4096)));
if (!dsoHandleName.empty())
}
if (atom->contentType() == lld::DefinedAtom::typeResolver)
desc |= N_SYMBOL_RESOLVER;
+ if (atom->contentType() == lld::DefinedAtom::typeMachHeader)
+ desc |= REFERENCED_DYNAMICALLY;
if (_archHandler.isThumbFunction(*atom))
desc |= N_ARM_THUMB_DEF;
if (atom->deadStrip() == DefinedAtom::deadStripNever) {
# CHECK: (undefined) external ___stdoutp (from libSystem)
# CHECK: (undefined) external _fprintf (from libSystem)
# CHECK: (undefined) external dyld_stub_binder (from libSystem)
+# CHECK: {{[0-9a-f]+}} (__TEXT,__text) [referenced dynamically] external __mh_execute_header
# CHECK: {{[0-9a-f]+}} (__TEXT,__text) external _main