[PATCH] D96164: [lld-macho] add code signature for native arm64 macOS
Greg McGary via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 5 11:08:23 PST 2021
gkm created this revision.
gkm added a reviewer: lld-macho.
Herald added a subscriber: kristof.beyls.
Herald added a reviewer: int3.
gkm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
ARM64 macOS requires that a program have an ad hoc signature, otherwise the kernel will immediately reject it.
Ultimately, we want to add ad-hoc signing C++ code to lld, but for now, we just fork+exec `/usr/bin/codesign -s - PROGRAM`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96164
Files:
lld/MachO/Writer.cpp
Index: lld/MachO/Writer.cpp
===================================================================
--- lld/MachO/Writer.cpp
+++ 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(); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96164.321832.patch
Type: text/x-patch
Size: 855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210205/2e49afda/attachment.bin>
More information about the llvm-commits
mailing list