+
+
+
+ if (inherit & kSecCodeSignerPreservePEH) {
+ /* We need at least one architecture in all cases because we index our
+ * PreEncryptionMaps by architecture. However, only machOs have any
+ * architecture at all, for generic targets there will just be one
+ * PreEncryptionHashMap.
+ * So if the main executable is not a machO, we just choose the local
+ * (signer's) main architecture as dummy value for the first element in our pair. */
+ preEncryptMainArch = (code->diskRep()->mainExecutableIsMachO() ?
+ code->diskRep()->mainExecutableImage()->bestNativeArch() :
+ Architecture::local());
+
+ addPreEncryptHashes(preEncryptHashMaps[preEncryptMainArch], code);
+
+ code->handleOtherArchitectures(^(Security::CodeSigning::SecStaticCode *subcode) {
+ Universal *fat = subcode->diskRep()->mainExecutableImage();
+ assert(fat && fat->narrowed()); // handleOtherArchitectures gave us a focused architecture slice.
+ Architecture arch = fat->bestNativeArch(); // actually, only architecture for this slice.
+ addPreEncryptHashes(preEncryptHashMaps[arch], subcode);
+ });
+ }
+
+ if (inherit & kSecCodeSignerPreserveRuntime) {
+ /* We need at least one architecture in all cases because we index our
+ * RuntimeVersionMaps by architecture. However, only machOs have any
+ * architecture at all, for generic targets there will just be one
+ * RuntimeVersionMap.
+ * So if the main executable is not a machO, we just choose the local
+ * (signer's) main architecture as dummy value for the first element in our pair. */
+ runtimeVersionMainArch = (code->diskRep()->mainExecutableIsMachO() ?
+ code->diskRep()->mainExecutableImage()->bestNativeArch() :
+ Architecture::local());
+
+ addRuntimeVersions(runtimeVersionMap[runtimeVersionMainArch], code);
+
+ code->handleOtherArchitectures(^(Security::CodeSigning::SecStaticCode *subcode) {
+ Universal *fat = subcode->diskRep()->mainExecutableImage();
+ assert(fat && fat->narrowed()); // handleOtherArchitectures gave us a focused architecture slice.
+ Architecture arch = fat->bestNativeArch(); // actually, only architecture for this slice.
+ addRuntimeVersions(runtimeVersionMap[arch], subcode);
+ });
+ }