Commit 8b5d5f44e2

Jakub Konka <kubkon@jakubkonka.com>
2022-04-01 14:33:37
macho: set CS_LINKER_SIGNED flag in code signature generated by zld
This way, if the user wants to use `codesign` (or other tool) they will not be forced to `-f` force signature update. This matches the behavior promoted by Apple's `ld64` linker.
1 parent fd29ddc
Changed files (2)
lib
src
lib/std/macho.zig
@@ -1718,6 +1718,7 @@ pub const CS_SIGNER_TYPE_LEGACYVPN: u32 = 5;
 pub const CS_SIGNER_TYPE_MAC_APP_STORE: u32 = 6;
 
 pub const CS_ADHOC: u32 = 0x2;
+pub const CS_LINKER_SIGNED: u32 = 0x20000;
 
 pub const CS_EXECSEG_MAIN_BINARY: u32 = 0x1;
 
src/link/MachO/CodeSignature.zig
@@ -60,7 +60,7 @@ const CodeDirectory = struct {
                 .magic = macho.CSMAGIC_CODEDIRECTORY,
                 .length = @sizeOf(macho.CodeDirectory),
                 .version = macho.CS_SUPPORTSEXECSEG,
-                .flags = macho.CS_ADHOC,
+                .flags = macho.CS_ADHOC | macho.CS_LINKER_SIGNED,
                 .hashOffset = 0,
                 .identOffset = @sizeOf(macho.CodeDirectory),
                 .nSpecialSlots = 0,