| ... | @@ -43,7 +43,7 @@ pub const fat_arch = extern struct { | ... | @@ -43,7 +43,7 @@ pub const fat_arch = extern struct { |
| 43 | }; | 43 | }; |
| 44 | | 44 | |
| 45 | pub const load_command = extern struct { | 45 | pub const load_command = extern struct { |
| 46 | cmd: u32, | 46 | cmd: LC, |
| 47 | cmdsize: u32, | 47 | cmdsize: u32, |
| 48 | }; | 48 | }; |
| 49 | | 49 | |
| ... | @@ -51,7 +51,7 @@ pub const load_command = extern struct { | ... | @@ -51,7 +51,7 @@ pub const load_command = extern struct { |
| 51 | /// identifies an object produced by the static link editor. | 51 | /// identifies an object produced by the static link editor. |
| 52 | pub const uuid_command = extern struct { | 52 | pub const uuid_command = extern struct { |
| 53 | /// LC_UUID | 53 | /// LC_UUID |
| 54 | cmd: u32, | 54 | cmd: LC = .UUID, |
| 55 | | 55 | |
| 56 | /// sizeof(struct uuid_command) | 56 | /// sizeof(struct uuid_command) |
| 57 | cmdsize: u32, | 57 | cmdsize: u32, |
| ... | @@ -64,7 +64,7 @@ pub const uuid_command = extern struct { | ... | @@ -64,7 +64,7 @@ pub const uuid_command = extern struct { |
| 64 | /// binary was built to run. | 64 | /// binary was built to run. |
| 65 | pub const version_min_command = extern struct { | 65 | pub const version_min_command = extern struct { |
| 66 | /// LC_VERSION_MIN_MACOSX or LC_VERSION_MIN_IPHONEOS or LC_VERSION_MIN_WATCHOS or LC_VERSION_MIN_TVOS | 66 | /// LC_VERSION_MIN_MACOSX or LC_VERSION_MIN_IPHONEOS or LC_VERSION_MIN_WATCHOS or LC_VERSION_MIN_TVOS |
| 67 | cmd: u32, | 67 | cmd: LC, |
| 68 | | 68 | |
| 69 | /// sizeof(struct version_min_command) | 69 | /// sizeof(struct version_min_command) |
| 70 | cmdsize: u32, | 70 | cmdsize: u32, |
| ... | @@ -80,7 +80,7 @@ pub const version_min_command = extern struct { | ... | @@ -80,7 +80,7 @@ pub const version_min_command = extern struct { |
| 80 | /// the version of the sources used to build the binary. | 80 | /// the version of the sources used to build the binary. |
| 81 | pub const source_version_command = extern struct { | 81 | pub const source_version_command = extern struct { |
| 82 | /// LC_SOURCE_VERSION | 82 | /// LC_SOURCE_VERSION |
| 83 | cmd: u32, | 83 | cmd: LC = .SOURCE_VERSION, |
| 84 | | 84 | |
| 85 | /// sizeof(source_version_command) | 85 | /// sizeof(source_version_command) |
| 86 | cmdsize: u32, | 86 | cmdsize: u32, |
| ... | @@ -94,14 +94,14 @@ pub const source_version_command = extern struct { | ... | @@ -94,14 +94,14 @@ pub const source_version_command = extern struct { |
| 94 | /// tool values following it. | 94 | /// tool values following it. |
| 95 | pub const build_version_command = extern struct { | 95 | pub const build_version_command = extern struct { |
| 96 | /// LC_BUILD_VERSION | 96 | /// LC_BUILD_VERSION |
| 97 | cmd: u32, | 97 | cmd: LC = .BUILD_VERSION, |
| 98 | | 98 | |
| 99 | /// sizeof(struct build_version_command) plus | 99 | /// sizeof(struct build_version_command) plus |
| 100 | /// ntools * sizeof(struct build_version_command) | 100 | /// ntools * sizeof(struct build_version_command) |
| 101 | cmdsize: u32, | 101 | cmdsize: u32, |
| 102 | | 102 | |
| 103 | /// platform | 103 | /// platform |
| 104 | platform: u32, | 104 | platform: PLATFORM, |
| 105 | | 105 | |
| 106 | /// X.Y.Z is encoded in nibbles xxxx.yy.zz | 106 | /// X.Y.Z is encoded in nibbles xxxx.yy.zz |
| 107 | minos: u32, | 107 | minos: u32, |
| ... | @@ -115,26 +115,32 @@ pub const build_version_command = extern struct { | ... | @@ -115,26 +115,32 @@ pub const build_version_command = extern struct { |
| 115 | | 115 | |
| 116 | pub const build_tool_version = extern struct { | 116 | pub const build_tool_version = extern struct { |
| 117 | /// enum for the tool | 117 | /// enum for the tool |
| 118 | tool: u32, | 118 | tool: TOOL, |
| 119 | | 119 | |
| 120 | /// version number of the tool | 120 | /// version number of the tool |
| 121 | version: u32, | 121 | version: u32, |
| 122 | }; | 122 | }; |
| 123 | | 123 | |
| 124 | pub const PLATFORM_MACOS: u32 = 0x1; | 124 | pub const PLATFORM = enum(u32) { |
| 125 | pub const PLATFORM_IOS: u32 = 0x2; | 125 | MACOS = 0x1, |
| 126 | pub const PLATFORM_TVOS: u32 = 0x3; | 126 | IOS = 0x2, |
| 127 | pub const PLATFORM_WATCHOS: u32 = 0x4; | 127 | TVOS = 0x3, |
| 128 | pub const PLATFORM_BRIDGEOS: u32 = 0x5; | 128 | WATCHOS = 0x4, |
| 129 | pub const PLATFORM_MACCATALYST: u32 = 0x6; | 129 | BRIDGEOS = 0x5, |
| 130 | pub const PLATFORM_IOSSIMULATOR: u32 = 0x7; | 130 | MACCATALYST = 0x6, |
| 131 | pub const PLATFORM_TVOSSIMULATOR: u32 = 0x8; | 131 | IOSSIMULATOR = 0x7, |
| 132 | pub const PLATFORM_WATCHOSSIMULATOR: u32 = 0x9; | 132 | TVOSSIMULATOR = 0x8, |
| 133 | pub const PLATFORM_DRIVERKIT: u32 = 0x10; | 133 | WATCHOSSIMULATOR = 0x9, |
| 134 | | 134 | DRIVERKIT = 0x10, |
| 135 | pub const TOOL_CLANG: u32 = 0x1; | 135 | _, |
| 136 | pub const TOOL_SWIFT: u32 = 0x2; | 136 | }; |
| 137 | pub const TOOL_LD: u32 = 0x3; | 137 | |
| | 138 | pub const TOOL = enum(u32) { |
| | 139 | CLANG = 0x1, |
| | 140 | SWIFT = 0x2, |
| | 141 | LD = 0x3, |
| | 142 | _, |
| | 143 | }; |
| 138 | | 144 | |
| 139 | /// The entry_point_command is a replacement for thread_command. | 145 | /// The entry_point_command is a replacement for thread_command. |
| 140 | /// It is used for main executables to specify the location (file offset) | 146 | /// It is used for main executables to specify the location (file offset) |
| ... | @@ -142,7 +148,7 @@ pub const TOOL_LD: u32 = 0x3; | ... | @@ -142,7 +148,7 @@ pub const TOOL_LD: u32 = 0x3; |
| 142 | /// field will contain the stack size needed for the main thread. | 148 | /// field will contain the stack size needed for the main thread. |
| 143 | pub const entry_point_command = extern struct { | 149 | pub const entry_point_command = extern struct { |
| 144 | /// LC_MAIN only used in MH_EXECUTE filetypes | 150 | /// LC_MAIN only used in MH_EXECUTE filetypes |
| 145 | cmd: u32, | 151 | cmd: LC = .MAIN, |
| 146 | | 152 | |
| 147 | /// sizeof(struct entry_point_command) | 153 | /// sizeof(struct entry_point_command) |
| 148 | cmdsize: u32, | 154 | cmdsize: u32, |
| ... | @@ -159,7 +165,7 @@ pub const entry_point_command = extern struct { | ... | @@ -159,7 +165,7 @@ pub const entry_point_command = extern struct { |
| 159 | /// <nlist.h> and <stab.h>. | 165 | /// <nlist.h> and <stab.h>. |
| 160 | pub const symtab_command = extern struct { | 166 | pub const symtab_command = extern struct { |
| 161 | /// LC_SYMTAB | 167 | /// LC_SYMTAB |
| 162 | cmd: u32, | 168 | cmd: LC = .SYMTAB, |
| 163 | | 169 | |
| 164 | /// sizeof(struct symtab_command) | 170 | /// sizeof(struct symtab_command) |
| 165 | cmdsize: u32, | 171 | cmdsize: u32, |
| ... | @@ -217,7 +223,7 @@ pub const symtab_command = extern struct { | ... | @@ -217,7 +223,7 @@ pub const symtab_command = extern struct { |
| 217 | /// off the section structures. | 223 | /// off the section structures. |
| 218 | pub const dysymtab_command = extern struct { | 224 | pub const dysymtab_command = extern struct { |
| 219 | /// LC_DYSYMTAB | 225 | /// LC_DYSYMTAB |
| 220 | cmd: u32, | 226 | cmd: LC = .DYSYMTAB, |
| 221 | | 227 | |
| 222 | /// sizeof(struct dysymtab_command) | 228 | /// sizeof(struct dysymtab_command) |
| 223 | cmdsize: u32, | 229 | cmdsize: u32, |
| ... | @@ -357,7 +363,7 @@ pub const dysymtab_command = extern struct { | ... | @@ -357,7 +363,7 @@ pub const dysymtab_command = extern struct { |
| 357 | /// of data in the __LINKEDIT segment. | 363 | /// of data in the __LINKEDIT segment. |
| 358 | pub const linkedit_data_command = extern struct { | 364 | pub const linkedit_data_command = extern struct { |
| 359 | /// LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_DYLIB_CODE_SIGN_DRS or LC_LINKER_OPTIMIZATION_HINT. | 365 | /// LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_DYLIB_CODE_SIGN_DRS or LC_LINKER_OPTIMIZATION_HINT. |
| 360 | cmd: u32, | 366 | cmd: LC, |
| 361 | | 367 | |
| 362 | /// sizeof(struct linkedit_data_command) | 368 | /// sizeof(struct linkedit_data_command) |
| 363 | cmdsize: u32, | 369 | cmdsize: u32, |
| ... | @@ -377,7 +383,7 @@ pub const linkedit_data_command = extern struct { | ... | @@ -377,7 +383,7 @@ pub const linkedit_data_command = extern struct { |
| 377 | /// to interpret it. | 383 | /// to interpret it. |
| 378 | pub const dyld_info_command = extern struct { | 384 | pub const dyld_info_command = extern struct { |
| 379 | /// LC_DYLD_INFO or LC_DYLD_INFO_ONLY | 385 | /// LC_DYLD_INFO or LC_DYLD_INFO_ONLY |
| 380 | cmd: u32, | 386 | cmd: LC, |
| 381 | | 387 | |
| 382 | /// sizeof(struct dyld_info_command) | 388 | /// sizeof(struct dyld_info_command) |
| 383 | cmdsize: u32, | 389 | cmdsize: u32, |
| ... | @@ -498,7 +504,7 @@ pub const dyld_info_command = extern struct { | ... | @@ -498,7 +504,7 @@ pub const dyld_info_command = extern struct { |
| 498 | /// string for dyld to treat like an environment variable. | 504 | /// string for dyld to treat like an environment variable. |
| 499 | pub const dylinker_command = extern struct { | 505 | pub const dylinker_command = extern struct { |
| 500 | /// LC_ID_DYLINKER, LC_LOAD_DYLINKER, or LC_DYLD_ENVIRONMENT | 506 | /// LC_ID_DYLINKER, LC_LOAD_DYLINKER, or LC_DYLD_ENVIRONMENT |
| 501 | cmd: u32, | 507 | cmd: LC, |
| 502 | | 508 | |
| 503 | /// includes pathname string | 509 | /// includes pathname string |
| 504 | cmdsize: u32, | 510 | cmdsize: u32, |
| ... | @@ -519,7 +525,7 @@ pub const dylinker_command = extern struct { | ... | @@ -519,7 +525,7 @@ pub const dylinker_command = extern struct { |
| 519 | /// LC_REEXPORT_DYLIB) for each library it uses. | 525 | /// LC_REEXPORT_DYLIB) for each library it uses. |
| 520 | pub const dylib_command = extern struct { | 526 | pub const dylib_command = extern struct { |
| 521 | /// LC_ID_DYLIB, LC_LOAD_WEAK_DYLIB, LC_LOAD_DYLIB, LC_REEXPORT_DYLIB | 527 | /// LC_ID_DYLIB, LC_LOAD_WEAK_DYLIB, LC_LOAD_DYLIB, LC_REEXPORT_DYLIB |
| 522 | cmd: u32, | 528 | cmd: LC, |
| 523 | | 529 | |
| 524 | /// includes pathname string | 530 | /// includes pathname string |
| 525 | cmdsize: u32, | 531 | cmdsize: u32, |
| ... | @@ -553,7 +559,7 @@ pub const dylib = extern struct { | ... | @@ -553,7 +559,7 @@ pub const dylib = extern struct { |
| 553 | /// run path used to find @rpath prefixed dylibs. | 559 | /// run path used to find @rpath prefixed dylibs. |
| 554 | pub const rpath_command = extern struct { | 560 | pub const rpath_command = extern struct { |
| 555 | /// LC_RPATH | 561 | /// LC_RPATH |
| 556 | cmd: u32, | 562 | cmd: LC = .RPATH, |
| 557 | | 563 | |
| 558 | /// includes string | 564 | /// includes string |
| 559 | cmdsize: u32, | 565 | cmdsize: u32, |
| ... | @@ -574,7 +580,7 @@ pub const rpath_command = extern struct { | ... | @@ -574,7 +580,7 @@ pub const rpath_command = extern struct { |
| 574 | /// reflected in cmdsize. | 580 | /// reflected in cmdsize. |
| 575 | pub const segment_command = extern struct { | 581 | pub const segment_command = extern struct { |
| 576 | /// LC_SEGMENT | 582 | /// LC_SEGMENT |
| 577 | cmd: u32, | 583 | cmd: LC = .SEGMENT, |
| 578 | | 584 | |
| 579 | /// includes sizeof section structs | 585 | /// includes sizeof section structs |
| 580 | cmdsize: u32, | 586 | cmdsize: u32, |
| ... | @@ -611,7 +617,7 @@ pub const segment_command = extern struct { | ... | @@ -611,7 +617,7 @@ pub const segment_command = extern struct { |
| 611 | /// command and their size is reflected in cmdsize. | 617 | /// command and their size is reflected in cmdsize. |
| 612 | pub const segment_command_64 = extern struct { | 618 | pub const segment_command_64 = extern struct { |
| 613 | /// LC_SEGMENT_64 | 619 | /// LC_SEGMENT_64 |
| 614 | cmd: u32 = LC_SEGMENT_64, | 620 | cmd: LC = .SEGMENT_64, |
| 615 | | 621 | |
| 616 | /// includes sizeof section_64 structs | 622 | /// includes sizeof section_64 structs |
| 617 | cmdsize: u32 = @sizeOf(segment_command_64), | 623 | cmdsize: u32 = @sizeOf(segment_command_64), |
| ... | @@ -882,159 +888,163 @@ pub const relocation_info = packed struct { | ... | @@ -882,159 +888,163 @@ pub const relocation_info = packed struct { |
| 882 | /// simply be ignored. | 888 | /// simply be ignored. |
| 883 | pub const LC_REQ_DYLD = 0x80000000; | 889 | pub const LC_REQ_DYLD = 0x80000000; |
| 884 | | 890 | |
| 885 | /// segment of this file to be mapped | 891 | pub const LC = enum(u32) { |
| 886 | pub const LC_SEGMENT = 0x1; | 892 | /// segment of this file to be mapped |
| | 893 | SEGMENT = 0x1, |
| 887 | | 894 | |
| 888 | /// link-edit stab symbol table info | 895 | /// link-edit stab symbol table info |
| 889 | pub const LC_SYMTAB = 0x2; | 896 | SYMTAB = 0x2, |
| 890 | | 897 | |
| 891 | /// link-edit gdb symbol table info (obsolete) | 898 | /// link-edit gdb symbol table info (obsolete) |
| 892 | pub const LC_SYMSEG = 0x3; | 899 | SYMSEG = 0x3, |
| 893 | | 900 | |
| 894 | /// thread | 901 | /// thread |
| 895 | pub const LC_THREAD = 0x4; | 902 | THREAD = 0x4, |
| 896 | | 903 | |
| 897 | /// unix thread (includes a stack) | 904 | /// unix thread (includes a stack) |
| 898 | pub const LC_UNIXTHREAD = 0x5; | 905 | UNIXTHREAD = 0x5, |
| 899 | | 906 | |
| 900 | /// load a specified fixed VM shared library | 907 | /// load a specified fixed VM shared library |
| 901 | pub const LC_LOADFVMLIB = 0x6; | 908 | LOADFVMLIB = 0x6, |
| 902 | | 909 | |
| 903 | /// fixed VM shared library identification | 910 | /// fixed VM shared library identification |
| 904 | pub const LC_IDFVMLIB = 0x7; | 911 | IDFVMLIB = 0x7, |
| 905 | | 912 | |
| 906 | /// object identification info (obsolete) | 913 | /// object identification info (obsolete) |
| 907 | pub const LC_IDENT = 0x8; | 914 | IDENT = 0x8, |
| 908 | | 915 | |
| 909 | /// fixed VM file inclusion (internal use) | 916 | /// fixed VM file inclusion (internal use) |
| 910 | pub const LC_FVMFILE = 0x9; | 917 | FVMFILE = 0x9, |
| 911 | | 918 | |
| 912 | /// prepage command (internal use) | 919 | /// prepage command (internal use) |
| 913 | pub const LC_PREPAGE = 0xa; | 920 | PREPAGE = 0xa, |
| 914 | | 921 | |
| 915 | /// dynamic link-edit symbol table info | 922 | /// dynamic link-edit symbol table info |
| 916 | pub const LC_DYSYMTAB = 0xb; | 923 | DYSYMTAB = 0xb, |
| 917 | | 924 | |
| 918 | /// load a dynamically linked shared library | 925 | /// load a dynamically linked shared library |
| 919 | pub const LC_LOAD_DYLIB = 0xc; | 926 | LOAD_DYLIB = 0xc, |
| 920 | | 927 | |
| 921 | /// dynamically linked shared lib ident | 928 | /// dynamically linked shared lib ident |
| 922 | pub const LC_ID_DYLIB = 0xd; | 929 | ID_DYLIB = 0xd, |
| 923 | | 930 | |
| 924 | /// load a dynamic linker | 931 | /// load a dynamic linker |
| 925 | pub const LC_LOAD_DYLINKER = 0xe; | 932 | LOAD_DYLINKER = 0xe, |
| 926 | | 933 | |
| 927 | /// dynamic linker identification | 934 | /// dynamic linker identification |
| 928 | pub const LC_ID_DYLINKER = 0xf; | 935 | ID_DYLINKER = 0xf, |
| 929 | | 936 | |
| 930 | /// modules prebound for a dynamically | 937 | /// modules prebound for a dynamically |
| 931 | pub const LC_PREBOUND_DYLIB = 0x10; | 938 | PREBOUND_DYLIB = 0x10, |
| 932 | | 939 | |
| 933 | /// image routines | 940 | /// image routines |
| 934 | pub const LC_ROUTINES = 0x11; | 941 | ROUTINES = 0x11, |
| 935 | | 942 | |
| 936 | /// sub framework | 943 | /// sub framework |
| 937 | pub const LC_SUB_FRAMEWORK = 0x12; | 944 | SUB_FRAMEWORK = 0x12, |
| 938 | | 945 | |
| 939 | /// sub umbrella | 946 | /// sub umbrella |
| 940 | pub const LC_SUB_UMBRELLA = 0x13; | 947 | SUB_UMBRELLA = 0x13, |
| 941 | | 948 | |
| 942 | /// sub client | 949 | /// sub client |
| 943 | pub const LC_SUB_CLIENT = 0x14; | 950 | SUB_CLIENT = 0x14, |
| 944 | | 951 | |
| 945 | /// sub library | 952 | /// sub library |
| 946 | pub const LC_SUB_LIBRARY = 0x15; | 953 | SUB_LIBRARY = 0x15, |
| 947 | | 954 | |
| 948 | /// two-level namespace lookup hints | 955 | /// two-level namespace lookup hints |
| 949 | pub const LC_TWOLEVEL_HINTS = 0x16; | 956 | TWOLEVEL_HINTS = 0x16, |
| 950 | | 957 | |
| 951 | /// prebind checksum | 958 | /// prebind checksum |
| 952 | pub const LC_PREBIND_CKSUM = 0x17; | 959 | PREBIND_CKSUM = 0x17, |
| 953 | | 960 | |
| 954 | /// load a dynamically linked shared library that is allowed to be missing | 961 | /// load a dynamically linked shared library that is allowed to be missing |
| 955 | /// (all symbols are weak imported). | 962 | /// (all symbols are weak imported). |
| 956 | pub const LC_LOAD_WEAK_DYLIB = (0x18 | LC_REQ_DYLD); | 963 | LOAD_WEAK_DYLIB = (0x18 | LC_REQ_DYLD), |
| 957 | | 964 | |
| 958 | /// 64-bit segment of this file to be mapped | 965 | /// 64-bit segment of this file to be mapped |
| 959 | pub const LC_SEGMENT_64 = 0x19; | 966 | SEGMENT_64 = 0x19, |
| 960 | | 967 | |
| 961 | /// 64-bit image routines | 968 | /// 64-bit image routines |
| 962 | pub const LC_ROUTINES_64 = 0x1a; | 969 | ROUTINES_64 = 0x1a, |
| 963 | | 970 | |
| 964 | /// the uuid | 971 | /// the uuid |
| 965 | pub const LC_UUID = 0x1b; | 972 | UUID = 0x1b, |
| 966 | | 973 | |
| 967 | /// runpath additions | 974 | /// runpath additions |
| 968 | pub const LC_RPATH = (0x1c | LC_REQ_DYLD); | 975 | RPATH = (0x1c | LC_REQ_DYLD), |
| 969 | | 976 | |
| 970 | /// local of code signature | 977 | /// local of code signature |
| 971 | pub const LC_CODE_SIGNATURE = 0x1d; | 978 | CODE_SIGNATURE = 0x1d, |
| 972 | | 979 | |
| 973 | /// local of info to split segments | 980 | /// local of info to split segments |
| 974 | pub const LC_SEGMENT_SPLIT_INFO = 0x1e; | 981 | SEGMENT_SPLIT_INFO = 0x1e, |
| 975 | | 982 | |
| 976 | /// load and re-export dylib | 983 | /// load and re-export dylib |
| 977 | pub const LC_REEXPORT_DYLIB = (0x1f | LC_REQ_DYLD); | 984 | REEXPORT_DYLIB = (0x1f | LC_REQ_DYLD), |
| 978 | | 985 | |
| 979 | /// delay load of dylib until first use | 986 | /// delay load of dylib until first use |
| 980 | pub const LC_LAZY_LOAD_DYLIB = 0x20; | 987 | LAZY_LOAD_DYLIB = 0x20, |
| 981 | | 988 | |
| 982 | /// encrypted segment information | 989 | /// encrypted segment information |
| 983 | pub const LC_ENCRYPTION_INFO = 0x21; | 990 | ENCRYPTION_INFO = 0x21, |
| 984 | | 991 | |
| 985 | /// compressed dyld information | 992 | /// compressed dyld information |
| 986 | pub const LC_DYLD_INFO = 0x22; | 993 | DYLD_INFO = 0x22, |
| 987 | | 994 | |
| 988 | /// compressed dyld information only | 995 | /// compressed dyld information only |
| 989 | pub const LC_DYLD_INFO_ONLY = (0x22 | LC_REQ_DYLD); | 996 | DYLD_INFO_ONLY = (0x22 | LC_REQ_DYLD), |
| 990 | | 997 | |
| 991 | /// load upward dylib | 998 | /// load upward dylib |
| 992 | pub const LC_LOAD_UPWARD_DYLIB = (0x23 | LC_REQ_DYLD); | 999 | LOAD_UPWARD_DYLIB = (0x23 | LC_REQ_DYLD), |
| 993 | | 1000 | |
| 994 | /// build for MacOSX min OS version | 1001 | /// build for MacOSX min OS version |
| 995 | pub const LC_VERSION_MIN_MACOSX = 0x24; | 1002 | VERSION_MIN_MACOSX = 0x24, |
| 996 | | 1003 | |
| 997 | /// build for iPhoneOS min OS version | 1004 | /// build for iPhoneOS min OS version |
| 998 | pub const LC_VERSION_MIN_IPHONEOS = 0x25; | 1005 | VERSION_MIN_IPHONEOS = 0x25, |
| 999 | | 1006 | |
| 1000 | /// compressed table of function start addresses | 1007 | /// compressed table of function start addresses |
| 1001 | pub const LC_FUNCTION_STARTS = 0x26; | 1008 | FUNCTION_STARTS = 0x26, |
| 1002 | | 1009 | |
| 1003 | /// string for dyld to treat like environment variable | 1010 | /// string for dyld to treat like environment variable |
| 1004 | pub const LC_DYLD_ENVIRONMENT = 0x27; | 1011 | DYLD_ENVIRONMENT = 0x27, |
| 1005 | | 1012 | |
| 1006 | /// replacement for LC_UNIXTHREAD | 1013 | /// replacement for LC_UNIXTHREAD |
| 1007 | pub const LC_MAIN = (0x28 | LC_REQ_DYLD); | 1014 | MAIN = (0x28 | LC_REQ_DYLD), |
| 1008 | | 1015 | |
| 1009 | /// table of non-instructions in __text | 1016 | /// table of non-instructions in __text |
| 1010 | pub const LC_DATA_IN_CODE = 0x29; | 1017 | DATA_IN_CODE = 0x29, |
| 1011 | | 1018 | |
| 1012 | /// source version used to build binary | 1019 | /// source version used to build binary |
| 1013 | pub const LC_SOURCE_VERSION = 0x2A; | 1020 | SOURCE_VERSION = 0x2A, |
| 1014 | | 1021 | |
| 1015 | /// Code signing DRs copied from linked dylibs | 1022 | /// Code signing DRs copied from linked dylibs |
| 1016 | pub const LC_DYLIB_CODE_SIGN_DRS = 0x2B; | 1023 | DYLIB_CODE_SIGN_DRS = 0x2B, |
| 1017 | | 1024 | |
| 1018 | /// 64-bit encrypted segment information | 1025 | /// 64-bit encrypted segment information |
| 1019 | pub const LC_ENCRYPTION_INFO_64 = 0x2C; | 1026 | ENCRYPTION_INFO_64 = 0x2C, |
| 1020 | | 1027 | |
| 1021 | /// linker options in MH_OBJECT files | 1028 | /// linker options in MH_OBJECT files |
| 1022 | pub const LC_LINKER_OPTION = 0x2D; | 1029 | LINKER_OPTION = 0x2D, |
| 1023 | | 1030 | |
| 1024 | /// optimization hints in MH_OBJECT files | 1031 | /// optimization hints in MH_OBJECT files |
| 1025 | pub const LC_LINKER_OPTIMIZATION_HINT = 0x2E; | 1032 | LINKER_OPTIMIZATION_HINT = 0x2E, |
| 1026 | | 1033 | |
| 1027 | /// build for AppleTV min OS version | 1034 | /// build for AppleTV min OS version |
| 1028 | pub const LC_VERSION_MIN_TVOS = 0x2F; | 1035 | VERSION_MIN_TVOS = 0x2F, |
| 1029 | | 1036 | |
| 1030 | /// build for Watch min OS version | 1037 | /// build for Watch min OS version |
| 1031 | pub const LC_VERSION_MIN_WATCHOS = 0x30; | 1038 | VERSION_MIN_WATCHOS = 0x30, |
| 1032 | | 1039 | |
| 1033 | /// arbitrary data included within a Mach-O file | 1040 | /// arbitrary data included within a Mach-O file |
| 1034 | pub const LC_NOTE = 0x31; | 1041 | NOTE = 0x31, |
| 1035 | | 1042 | |
| 1036 | /// build for platform min OS version | 1043 | /// build for platform min OS version |
| 1037 | pub const LC_BUILD_VERSION = 0x32; | 1044 | BUILD_VERSION = 0x32, |
| | 1045 | |
| | 1046 | _, |
| | 1047 | }; |
| 1038 | | 1048 | |
| 1039 | /// the mach magic number | 1049 | /// the mach magic number |
| 1040 | pub const MH_MAGIC = 0xfeedface; | 1050 | pub const MH_MAGIC = 0xfeedface; |
| ... | @@ -1537,7 +1547,7 @@ pub const reloc_type_x86_64 = enum(u4) { | ... | @@ -1537,7 +1547,7 @@ pub const reloc_type_x86_64 = enum(u4) { |
| 1537 | | 1547 | |
| 1538 | pub const reloc_type_arm64 = enum(u4) { | 1548 | pub const reloc_type_arm64 = enum(u4) { |
| 1539 | /// For pointers. | 1549 | /// For pointers. |
| 1540 | ARM64_RELOC_UNSIGNED, | 1550 | ARM64_RELOC_UNSIGNED = 0, |
| 1541 | | 1551 | |
| 1542 | /// Must be followed by a ARM64_RELOC_UNSIGNED. | 1552 | /// Must be followed by a ARM64_RELOC_UNSIGNED. |
| 1543 | ARM64_RELOC_SUBTRACTOR, | 1553 | ARM64_RELOC_SUBTRACTOR, |
| ... | @@ -1840,43 +1850,43 @@ pub const LoadCommand = union(enum) { | ... | @@ -1840,43 +1850,43 @@ pub const LoadCommand = union(enum) { |
| 1840 | var stream = io.fixedBufferStream(buffer); | 1850 | var stream = io.fixedBufferStream(buffer); |
| 1841 | | 1851 | |
| 1842 | return switch (header.cmd) { | 1852 | return switch (header.cmd) { |
| 1843 | LC_SEGMENT_64 => LoadCommand{ | 1853 | .SEGMENT_64 => LoadCommand{ |
| 1844 | .segment = try SegmentCommand.read(allocator, stream.reader()), | 1854 | .segment = try SegmentCommand.read(allocator, stream.reader()), |
| 1845 | }, | 1855 | }, |
| 1846 | LC_DYLD_INFO, LC_DYLD_INFO_ONLY => LoadCommand{ | 1856 | .DYLD_INFO, .DYLD_INFO_ONLY => LoadCommand{ |
| 1847 | .dyld_info_only = try stream.reader().readStruct(dyld_info_command), | 1857 | .dyld_info_only = try stream.reader().readStruct(dyld_info_command), |
| 1848 | }, | 1858 | }, |
| 1849 | LC_SYMTAB => LoadCommand{ | 1859 | .SYMTAB => LoadCommand{ |
| 1850 | .symtab = try stream.reader().readStruct(symtab_command), | 1860 | .symtab = try stream.reader().readStruct(symtab_command), |
| 1851 | }, | 1861 | }, |
| 1852 | LC_DYSYMTAB => LoadCommand{ | 1862 | .DYSYMTAB => LoadCommand{ |
| 1853 | .dysymtab = try stream.reader().readStruct(dysymtab_command), | 1863 | .dysymtab = try stream.reader().readStruct(dysymtab_command), |
| 1854 | }, | 1864 | }, |
| 1855 | LC_ID_DYLINKER, LC_LOAD_DYLINKER, LC_DYLD_ENVIRONMENT => LoadCommand{ | 1865 | .ID_DYLINKER, .LOAD_DYLINKER, .DYLD_ENVIRONMENT => LoadCommand{ |
| 1856 | .dylinker = try GenericCommandWithData(dylinker_command).read(allocator, stream.reader()), | 1866 | .dylinker = try GenericCommandWithData(dylinker_command).read(allocator, stream.reader()), |
| 1857 | }, | 1867 | }, |
| 1858 | LC_ID_DYLIB, LC_LOAD_WEAK_DYLIB, LC_LOAD_DYLIB, LC_REEXPORT_DYLIB => LoadCommand{ | 1868 | .ID_DYLIB, .LOAD_WEAK_DYLIB, .LOAD_DYLIB, .REEXPORT_DYLIB => LoadCommand{ |
| 1859 | .dylib = try GenericCommandWithData(dylib_command).read(allocator, stream.reader()), | 1869 | .dylib = try GenericCommandWithData(dylib_command).read(allocator, stream.reader()), |
| 1860 | }, | 1870 | }, |
| 1861 | LC_MAIN => LoadCommand{ | 1871 | .MAIN => LoadCommand{ |
| 1862 | .main = try stream.reader().readStruct(entry_point_command), | 1872 | .main = try stream.reader().readStruct(entry_point_command), |
| 1863 | }, | 1873 | }, |
| 1864 | LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS, LC_VERSION_MIN_WATCHOS, LC_VERSION_MIN_TVOS => LoadCommand{ | 1874 | .VERSION_MIN_MACOSX, .VERSION_MIN_IPHONEOS, .VERSION_MIN_WATCHOS, .VERSION_MIN_TVOS => LoadCommand{ |
| 1865 | .version_min = try stream.reader().readStruct(version_min_command), | 1875 | .version_min = try stream.reader().readStruct(version_min_command), |
| 1866 | }, | 1876 | }, |
| 1867 | LC_SOURCE_VERSION => LoadCommand{ | 1877 | .SOURCE_VERSION => LoadCommand{ |
| 1868 | .source_version = try stream.reader().readStruct(source_version_command), | 1878 | .source_version = try stream.reader().readStruct(source_version_command), |
| 1869 | }, | 1879 | }, |
| 1870 | LC_BUILD_VERSION => LoadCommand{ | 1880 | .BUILD_VERSION => LoadCommand{ |
| 1871 | .build_version = try GenericCommandWithData(build_version_command).read(allocator, stream.reader()), | 1881 | .build_version = try GenericCommandWithData(build_version_command).read(allocator, stream.reader()), |
| 1872 | }, | 1882 | }, |
| 1873 | LC_UUID => LoadCommand{ | 1883 | .UUID => LoadCommand{ |
| 1874 | .uuid = try stream.reader().readStruct(uuid_command), | 1884 | .uuid = try stream.reader().readStruct(uuid_command), |
| 1875 | }, | 1885 | }, |
| 1876 | LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_CODE_SIGNATURE => LoadCommand{ | 1886 | .FUNCTION_STARTS, .DATA_IN_CODE, .CODE_SIGNATURE => LoadCommand{ |
| 1877 | .linkedit_data = try stream.reader().readStruct(linkedit_data_command), | 1887 | .linkedit_data = try stream.reader().readStruct(linkedit_data_command), |
| 1878 | }, | 1888 | }, |
| 1879 | LC_RPATH => LoadCommand{ | 1889 | .RPATH => LoadCommand{ |
| 1880 | .rpath = try GenericCommandWithData(rpath_command).read(allocator, stream.reader()), | 1890 | .rpath = try GenericCommandWithData(rpath_command).read(allocator, stream.reader()), |
| 1881 | }, | 1891 | }, |
| 1882 | else => LoadCommand{ | 1892 | else => LoadCommand{ |
| ... | @@ -1904,7 +1914,7 @@ pub const LoadCommand = union(enum) { | ... | @@ -1904,7 +1914,7 @@ pub const LoadCommand = union(enum) { |
| 1904 | }; | 1914 | }; |
| 1905 | } | 1915 | } |
| 1906 | | 1916 | |
| 1907 | pub fn cmd(self: LoadCommand) u32 { | 1917 | pub fn cmd(self: LoadCommand) LC { |
| 1908 | return switch (self) { | 1918 | return switch (self) { |
| 1909 | .dyld_info_only => |x| x.cmd, | 1919 | .dyld_info_only => |x| x.cmd, |
| 1910 | .symtab => |x| x.cmd, | 1920 | .symtab => |x| x.cmd, |
| ... | @@ -2078,7 +2088,7 @@ pub fn createLoadDylibCommand( | ... | @@ -2078,7 +2088,7 @@ pub fn createLoadDylibCommand( |
| 2078 | )); | 2088 | )); |
| 2079 | | 2089 | |
| 2080 | var dylib_cmd = emptyGenericCommandWithData(dylib_command{ | 2090 | var dylib_cmd = emptyGenericCommandWithData(dylib_command{ |
| 2081 | .cmd = LC_LOAD_DYLIB, | 2091 | .cmd = .LOAD_DYLIB, |
| 2082 | .cmdsize = cmdsize, | 2092 | .cmdsize = cmdsize, |
| 2083 | .dylib = .{ | 2093 | .dylib = .{ |
| 2084 | .name = @sizeOf(dylib_command), | 2094 | .name = @sizeOf(dylib_command), |
| ... | @@ -2189,7 +2199,7 @@ test "read-write generic command with data" { | ... | @@ -2189,7 +2199,7 @@ test "read-write generic command with data" { |
| 2189 | }; | 2199 | }; |
| 2190 | var cmd = GenericCommandWithData(dylib_command){ | 2200 | var cmd = GenericCommandWithData(dylib_command){ |
| 2191 | .inner = .{ | 2201 | .inner = .{ |
| 2192 | .cmd = LC_LOAD_DYLIB, | 2202 | .cmd = .LOAD_DYLIB, |
| 2193 | .cmdsize = 32, | 2203 | .cmdsize = 32, |
| 2194 | .dylib = .{ | 2204 | .dylib = .{ |
| 2195 | .name = 24, | 2205 | .name = 24, |
| ... | @@ -2227,7 +2237,7 @@ test "read-write C struct command" { | ... | @@ -2227,7 +2237,7 @@ test "read-write C struct command" { |
| 2227 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // stacksize | 2237 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // stacksize |
| 2228 | }; | 2238 | }; |
| 2229 | const cmd = .{ | 2239 | const cmd = .{ |
| 2230 | .cmd = LC_MAIN, | 2240 | .cmd = .MAIN, |
| 2231 | .cmdsize = 24, | 2241 | .cmdsize = 24, |
| 2232 | .entryoff = 16644, | 2242 | .entryoff = 16644, |
| 2233 | .stacksize = 0, | 2243 | .stacksize = 0, |