diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp --- a/lld/MachO/Writer.cpp +++ b/lld/MachO/Writer.cpp @@ -815,6 +815,16 @@ if (auto e = buffer->commit()) error("failed to write to the output file: " + toString(std::move(e))); + + // TODO(gkm): replace with code to populate the synthetic section + // LC_CODE_SIGNATURE. For sake of expediency during arm64 bring-up, + // just do it by fork+exec. + std::string codesign("/usr/bin/codesign"); + if (!errorCount() && config->outputType == MH_EXECUTE && + (config->arch == AK_arm64 || config->arch == AK_arm64e) && + config->platform.kind == PlatformKind::macOS && + sys::fs::can_execute(codesign.c_str())) + std::system((codesign + " -s - " + config->outputFile).str().c_str()); } void macho::writeResult() { Writer().run(); }