| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | | |
| 2 | 1 | pub const mach_header = extern struct { |
| 3 | 2 | magic: u32, |
| 4 | 3 | cputype: cpu_type_t, |
| ... | ... | @@ -25,26 +24,43 @@ pub const load_command = extern struct { |
| 25 | 24 | cmdsize: u32, |
| 26 | 25 | }; |
| 27 | 26 | |
| 28 | | |
| 29 | 27 | /// The symtab_command contains the offsets and sizes of the link-edit 4.3BSD |
| 30 | 28 | /// "stab" style symbol table information as described in the header files |
| 31 | 29 | /// <nlist.h> and <stab.h>. |
| 32 | 30 | pub const symtab_command = extern struct { |
| 33 | | cmd: u32, /// LC_SYMTAB |
| 34 | | cmdsize: u32, /// sizeof(struct symtab_command) |
| 35 | | symoff: u32, /// symbol table offset |
| 36 | | nsyms: u32, /// number of symbol table entries |
| 37 | | stroff: u32, /// string table offset |
| 38 | | strsize: u32, /// string table size in bytes |
| 31 | /// LC_SYMTAB |
| 32 | cmd: u32, |
| 33 | |
| 34 | /// sizeof(struct symtab_command) |
| 35 | cmdsize: u32, |
| 36 | |
| 37 | /// symbol table offset |
| 38 | symoff: u32, |
| 39 | |
| 40 | /// number of symbol table entries |
| 41 | nsyms: u32, |
| 42 | |
| 43 | /// string table offset |
| 44 | stroff: u32, |
| 45 | |
| 46 | /// string table size in bytes |
| 47 | strsize: u32, |
| 39 | 48 | }; |
| 40 | 49 | |
| 41 | 50 | /// The linkedit_data_command contains the offsets and sizes of a blob |
| 42 | | /// of data in the __LINKEDIT segment. |
| 51 | /// of data in the __LINKEDIT segment. |
| 43 | 52 | const linkedit_data_command = extern struct { |
| 44 | | cmd: u32,/// LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_DYLIB_CODE_SIGN_DRS or LC_LINKER_OPTIMIZATION_HINT. |
| 45 | | cmdsize: u32, /// sizeof(struct linkedit_data_command) |
| 46 | | dataoff: u32 , /// file offset of data in __LINKEDIT segment |
| 47 | | datasize: u32 , /// file size of data in __LINKEDIT segment |
| 53 | /// LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_DYLIB_CODE_SIGN_DRS or LC_LINKER_OPTIMIZATION_HINT. |
| 54 | cmd: u32, |
| 55 | |
| 56 | /// sizeof(struct linkedit_data_command) |
| 57 | cmdsize: u32, |
| 58 | |
| 59 | /// file offset of data in __LINKEDIT segment |
| 60 | dataoff: u32, |
| 61 | |
| 62 | /// file size of data in __LINKEDIT segment |
| 63 | datasize: u32, |
| 48 | 64 | }; |
| 49 | 65 | |
| 50 | 66 | /// The segment load command indicates that a part of this file is to be |
| ... | ... | @@ -58,16 +74,35 @@ const linkedit_data_command = extern struct { |
| 58 | 74 | /// section structures directly follow the segment command and their size is |
| 59 | 75 | /// reflected in cmdsize. |
| 60 | 76 | pub const segment_command = extern struct { |
| 61 | | cmd: u32,/// LC_SEGMENT |
| 62 | | cmdsize: u32,/// includes sizeof section structs |
| 63 | | segname: [16]u8,/// segment name |
| 64 | | vmaddr: u32,/// memory address of this segment |
| 65 | | vmsize: u32,/// memory size of this segment |
| 66 | | fileoff: u32,/// file offset of this segment |
| 67 | | filesize: u32,/// amount to map from the file |
| 68 | | maxprot: vm_prot_t,/// maximum VM protection |
| 69 | | initprot: vm_prot_t,/// initial VM protection |
| 70 | | nsects: u32,/// number of sections in segment |
| 77 | /// LC_SEGMENT |
| 78 | cmd: u32, |
| 79 | |
| 80 | /// includes sizeof section structs |
| 81 | cmdsize: u32, |
| 82 | |
| 83 | /// segment name |
| 84 | segname: [16]u8, |
| 85 | |
| 86 | /// memory address of this segment |
| 87 | vmaddr: u32, |
| 88 | |
| 89 | /// memory size of this segment |
| 90 | vmsize: u32, |
| 91 | |
| 92 | /// file offset of this segment |
| 93 | fileoff: u32, |
| 94 | |
| 95 | /// amount to map from the file |
| 96 | filesize: u32, |
| 97 | |
| 98 | /// maximum VM protection |
| 99 | maxprot: vm_prot_t, |
| 100 | |
| 101 | /// initial VM protection |
| 102 | initprot: vm_prot_t, |
| 103 | |
| 104 | /// number of sections in segment |
| 105 | nsects: u32, |
| 71 | 106 | flags: u32, |
| 72 | 107 | }; |
| 73 | 108 | |
| ... | ... | @@ -76,17 +111,36 @@ pub const segment_command = extern struct { |
| 76 | 111 | /// sections then section_64 structures directly follow the 64-bit segment |
| 77 | 112 | /// command and their size is reflected in cmdsize. |
| 78 | 113 | pub const segment_command_64 = extern struct { |
| 79 | | cmd: u32, /// LC_SEGMENT_64 |
| 80 | | cmdsize: u32, /// includes sizeof section_64 structs |
| 81 | | segname: [16]u8, /// segment name |
| 82 | | vmaddr: u64, /// memory address of this segment |
| 83 | | vmsize: u64, /// memory size of this segment |
| 84 | | fileoff: u64, /// file offset of this segment |
| 85 | | filesize: u64, /// amount to map from the file |
| 86 | | maxprot: vm_prot_t, /// maximum VM protection |
| 87 | | initprot: vm_prot_t, /// initial VM protection |
| 88 | | nsects: u32, /// number of sections in segment |
| 89 | | flags: u32, |
| 114 | /// LC_SEGMENT_64 |
| 115 | cmd: u32, |
| 116 | |
| 117 | /// includes sizeof section_64 structs |
| 118 | cmdsize: u32, |
| 119 | |
| 120 | /// segment name |
| 121 | segname: [16]u8, |
| 122 | |
| 123 | /// memory address of this segment |
| 124 | vmaddr: u64, |
| 125 | |
| 126 | /// memory size of this segment |
| 127 | vmsize: u64, |
| 128 | |
| 129 | /// file offset of this segment |
| 130 | fileoff: u64, |
| 131 | |
| 132 | /// amount to map from the file |
| 133 | filesize: u64, |
| 134 | |
| 135 | /// maximum VM protection |
| 136 | maxprot: vm_prot_t, |
| 137 | |
| 138 | /// initial VM protection |
| 139 | initprot: vm_prot_t, |
| 140 | |
| 141 | /// number of sections in segment |
| 142 | nsects: u32, |
| 143 | flags: u32, |
| 90 | 144 | }; |
| 91 | 145 | |
| 92 | 146 | /// A segment is made up of zero or more sections. Non-MH_OBJECT files have |
| ... | ... | @@ -115,32 +169,76 @@ pub const segment_command_64 = extern struct { |
| 115 | 169 | /// fields of the section structure for mach object files is described in the |
| 116 | 170 | /// header file <reloc.h>. |
| 117 | 171 | pub const @"section" = extern struct { |
| 118 | | sectname: [16]u8, /// name of this section |
| 119 | | segname: [16]u8, /// segment this section goes in |
| 120 | | addr: u32, /// memory address of this section |
| 121 | | size: u32, /// size in bytes of this section |
| 122 | | offset: u32, /// file offset of this section |
| 123 | | @"align": u32, /// section alignment (power of 2) |
| 124 | | reloff: u32, /// file offset of relocation entries |
| 125 | | nreloc: u32, /// number of relocation entries |
| 126 | | flags: u32, /// flags (section type and attributes |
| 127 | | reserved1: u32, /// reserved (for offset or index) |
| 128 | | reserved2: u32, /// reserved (for count or sizeof) |
| 172 | /// name of this section |
| 173 | sectname: [16]u8, |
| 174 | |
| 175 | /// segment this section goes in |
| 176 | segname: [16]u8, |
| 177 | |
| 178 | /// memory address of this section |
| 179 | addr: u32, |
| 180 | |
| 181 | /// size in bytes of this section |
| 182 | size: u32, |
| 183 | |
| 184 | /// file offset of this section |
| 185 | offset: u32, |
| 186 | |
| 187 | /// section alignment (power of 2) |
| 188 | @"align": u32, |
| 189 | |
| 190 | /// file offset of relocation entries |
| 191 | reloff: u32, |
| 192 | |
| 193 | /// number of relocation entries |
| 194 | nreloc: u32, |
| 195 | |
| 196 | /// flags (section type and attributes |
| 197 | flags: u32, |
| 198 | |
| 199 | /// reserved (for offset or index) |
| 200 | reserved1: u32, |
| 201 | |
| 202 | /// reserved (for count or sizeof) |
| 203 | reserved2: u32, |
| 129 | 204 | }; |
| 130 | 205 | |
| 131 | 206 | pub const section_64 = extern struct { |
| 132 | | sectname: [16]u8, /// name of this section |
| 133 | | segname: [16]u8, /// segment this section goes in |
| 134 | | addr: u64, /// memory address of this section |
| 135 | | size: u64, /// size in bytes of this section |
| 136 | | offset: u32, /// file offset of this section |
| 137 | | @"align": u32, /// section alignment (power of 2) |
| 138 | | reloff: u32, /// file offset of relocation entries |
| 139 | | nreloc: u32, /// number of relocation entries |
| 140 | | flags: u32, /// flags (section type and attributes |
| 141 | | reserved1: u32, /// reserved (for offset or index) |
| 142 | | reserved2: u32, /// reserved (for count or sizeof) |
| 143 | | reserved3: u32, /// reserved |
| 207 | /// name of this section |
| 208 | sectname: [16]u8, |
| 209 | |
| 210 | /// segment this section goes in |
| 211 | segname: [16]u8, |
| 212 | |
| 213 | /// memory address of this section |
| 214 | addr: u64, |
| 215 | |
| 216 | /// size in bytes of this section |
| 217 | size: u64, |
| 218 | |
| 219 | /// file offset of this section |
| 220 | offset: u32, |
| 221 | |
| 222 | /// section alignment (power of 2) |
| 223 | @"align": u32, |
| 224 | |
| 225 | /// file offset of relocation entries |
| 226 | reloff: u32, |
| 227 | |
| 228 | /// number of relocation entries |
| 229 | nreloc: u32, |
| 230 | |
| 231 | /// flags (section type and attributes |
| 232 | flags: u32, |
| 233 | |
| 234 | /// reserved (for offset or index) |
| 235 | reserved1: u32, |
| 236 | |
| 237 | /// reserved (for count or sizeof) |
| 238 | reserved2: u32, |
| 239 | |
| 240 | /// reserved |
| 241 | reserved3: u32, |
| 144 | 242 | }; |
| 145 | 243 | |
| 146 | 244 | pub const nlist = extern struct { |
| ... | ... | @@ -168,116 +266,287 @@ pub const nlist_64 = extern struct { |
| 168 | 266 | /// simply be ignored. |
| 169 | 267 | pub const LC_REQ_DYLD = 0x80000000; |
| 170 | 268 | |
| 171 | | pub const LC_SEGMENT = 0x1; /// segment of this file to be mapped |
| 172 | | pub const LC_SYMTAB = 0x2; /// link-edit stab symbol table info |
| 173 | | pub const LC_SYMSEG = 0x3; /// link-edit gdb symbol table info (obsolete) |
| 174 | | pub const LC_THREAD = 0x4; /// thread |
| 175 | | pub const LC_UNIXTHREAD = 0x5; /// unix thread (includes a stack) |
| 176 | | pub const LC_LOADFVMLIB = 0x6; /// load a specified fixed VM shared library |
| 177 | | pub const LC_IDFVMLIB = 0x7; /// fixed VM shared library identification |
| 178 | | pub const LC_IDENT = 0x8; /// object identification info (obsolete) |
| 179 | | pub const LC_FVMFILE = 0x9; /// fixed VM file inclusion (internal use) |
| 180 | | pub const LC_PREPAGE = 0xa; /// prepage command (internal use) |
| 181 | | pub const LC_DYSYMTAB = 0xb; /// dynamic link-edit symbol table info |
| 182 | | pub const LC_LOAD_DYLIB = 0xc; /// load a dynamically linked shared library |
| 183 | | pub const LC_ID_DYLIB = 0xd; /// dynamically linked shared lib ident |
| 184 | | pub const LC_LOAD_DYLINKER = 0xe; /// load a dynamic linker |
| 185 | | pub const LC_ID_DYLINKER = 0xf; /// dynamic linker identification |
| 186 | | pub const LC_PREBOUND_DYLIB = 0x10; /// modules prebound for a dynamically |
| 187 | | pub const LC_ROUTINES = 0x11; /// image routines |
| 188 | | pub const LC_SUB_FRAMEWORK = 0x12; /// sub framework |
| 189 | | pub const LC_SUB_UMBRELLA = 0x13; /// sub umbrella |
| 190 | | pub const LC_SUB_CLIENT = 0x14; /// sub client |
| 191 | | pub const LC_SUB_LIBRARY = 0x15; /// sub library |
| 192 | | pub const LC_TWOLEVEL_HINTS = 0x16; /// two-level namespace lookup hints |
| 193 | | pub const LC_PREBIND_CKSUM = 0x17; /// prebind checksum |
| 269 | /// segment of this file to be mapped |
| 270 | pub const LC_SEGMENT = 0x1; |
| 271 | |
| 272 | /// link-edit stab symbol table info |
| 273 | pub const LC_SYMTAB = 0x2; |
| 274 | |
| 275 | /// link-edit gdb symbol table info (obsolete) |
| 276 | pub const LC_SYMSEG = 0x3; |
| 277 | |
| 278 | /// thread |
| 279 | pub const LC_THREAD = 0x4; |
| 280 | |
| 281 | /// unix thread (includes a stack) |
| 282 | pub const LC_UNIXTHREAD = 0x5; |
| 283 | |
| 284 | /// load a specified fixed VM shared library |
| 285 | pub const LC_LOADFVMLIB = 0x6; |
| 286 | |
| 287 | /// fixed VM shared library identification |
| 288 | pub const LC_IDFVMLIB = 0x7; |
| 289 | |
| 290 | /// object identification info (obsolete) |
| 291 | pub const LC_IDENT = 0x8; |
| 292 | |
| 293 | /// fixed VM file inclusion (internal use) |
| 294 | pub const LC_FVMFILE = 0x9; |
| 295 | |
| 296 | /// prepage command (internal use) |
| 297 | pub const LC_PREPAGE = 0xa; |
| 298 | |
| 299 | /// dynamic link-edit symbol table info |
| 300 | pub const LC_DYSYMTAB = 0xb; |
| 301 | |
| 302 | /// load a dynamically linked shared library |
| 303 | pub const LC_LOAD_DYLIB = 0xc; |
| 304 | |
| 305 | /// dynamically linked shared lib ident |
| 306 | pub const LC_ID_DYLIB = 0xd; |
| 307 | |
| 308 | /// load a dynamic linker |
| 309 | pub const LC_LOAD_DYLINKER = 0xe; |
| 310 | |
| 311 | /// dynamic linker identification |
| 312 | pub const LC_ID_DYLINKER = 0xf; |
| 313 | |
| 314 | /// modules prebound for a dynamically |
| 315 | pub const LC_PREBOUND_DYLIB = 0x10; |
| 316 | |
| 317 | /// image routines |
| 318 | pub const LC_ROUTINES = 0x11; |
| 319 | |
| 320 | /// sub framework |
| 321 | pub const LC_SUB_FRAMEWORK = 0x12; |
| 322 | |
| 323 | /// sub umbrella |
| 324 | pub const LC_SUB_UMBRELLA = 0x13; |
| 325 | |
| 326 | /// sub client |
| 327 | pub const LC_SUB_CLIENT = 0x14; |
| 328 | |
| 329 | /// sub library |
| 330 | pub const LC_SUB_LIBRARY = 0x15; |
| 331 | |
| 332 | /// two-level namespace lookup hints |
| 333 | pub const LC_TWOLEVEL_HINTS = 0x16; |
| 334 | |
| 335 | /// prebind checksum |
| 336 | pub const LC_PREBIND_CKSUM = 0x17; |
| 194 | 337 | |
| 195 | 338 | /// load a dynamically linked shared library that is allowed to be missing |
| 196 | 339 | /// (all symbols are weak imported). |
| 197 | 340 | pub const LC_LOAD_WEAK_DYLIB = (0x18 | LC_REQ_DYLD); |
| 198 | 341 | |
| 199 | | pub const LC_SEGMENT_64 = 0x19; /// 64-bit segment of this file to be mapped |
| 200 | | pub const LC_ROUTINES_64 = 0x1a; /// 64-bit image routines |
| 201 | | pub const LC_UUID = 0x1b; /// the uuid |
| 202 | | pub const LC_RPATH = (0x1c | LC_REQ_DYLD); /// runpath additions |
| 203 | | pub const LC_CODE_SIGNATURE = 0x1d; /// local of code signature |
| 204 | | pub const LC_SEGMENT_SPLIT_INFO = 0x1e; /// local of info to split segments |
| 205 | | pub const LC_REEXPORT_DYLIB = (0x1f | LC_REQ_DYLD); /// load and re-export dylib |
| 206 | | pub const LC_LAZY_LOAD_DYLIB = 0x20; /// delay load of dylib until first use |
| 207 | | pub const LC_ENCRYPTION_INFO = 0x21; /// encrypted segment information |
| 208 | | pub const LC_DYLD_INFO = 0x22; /// compressed dyld information |
| 209 | | pub const LC_DYLD_INFO_ONLY = (0x22|LC_REQ_DYLD); /// compressed dyld information only |
| 210 | | pub const LC_LOAD_UPWARD_DYLIB = (0x23 | LC_REQ_DYLD); /// load upward dylib |
| 211 | | pub const LC_VERSION_MIN_MACOSX = 0x24; /// build for MacOSX min OS version |
| 212 | | pub const LC_VERSION_MIN_IPHONEOS = 0x25; /// build for iPhoneOS min OS version |
| 213 | | pub const LC_FUNCTION_STARTS = 0x26; /// compressed table of function start addresses |
| 214 | | pub const LC_DYLD_ENVIRONMENT = 0x27; /// string for dyld to treat like environment variable |
| 215 | | pub const LC_MAIN = (0x28|LC_REQ_DYLD); /// replacement for LC_UNIXTHREAD |
| 216 | | pub const LC_DATA_IN_CODE = 0x29; /// table of non-instructions in __text |
| 217 | | pub const LC_SOURCE_VERSION = 0x2A; /// source version used to build binary |
| 218 | | pub const LC_DYLIB_CODE_SIGN_DRS = 0x2B; /// Code signing DRs copied from linked dylibs |
| 219 | | pub const LC_ENCRYPTION_INFO_64 = 0x2C; /// 64-bit encrypted segment information |
| 220 | | pub const LC_LINKER_OPTION = 0x2D; /// linker options in MH_OBJECT files |
| 221 | | pub const LC_LINKER_OPTIMIZATION_HINT = 0x2E; /// optimization hints in MH_OBJECT files |
| 222 | | pub const LC_VERSION_MIN_TVOS = 0x2F; /// build for AppleTV min OS version |
| 223 | | pub const LC_VERSION_MIN_WATCHOS = 0x30; /// build for Watch min OS version |
| 224 | | pub const LC_NOTE = 0x31; /// arbitrary data included within a Mach-O file |
| 225 | | pub const LC_BUILD_VERSION = 0x32; /// build for platform min OS version |
| 226 | | |
| 227 | | pub const MH_MAGIC = 0xfeedface; /// the mach magic number |
| 228 | | pub const MH_CIGAM = 0xcefaedfe; /// NXSwapInt(MH_MAGIC) |
| 229 | | |
| 230 | | pub const MH_MAGIC_64 = 0xfeedfacf; /// the 64-bit mach magic number |
| 231 | | pub const MH_CIGAM_64 = 0xcffaedfe; /// NXSwapInt(MH_MAGIC_64) |
| 232 | | |
| 233 | | pub const MH_OBJECT = 0x1; /// relocatable object file |
| 234 | | pub const MH_EXECUTE = 0x2; /// demand paged executable file |
| 235 | | pub const MH_FVMLIB = 0x3; /// fixed VM shared library file |
| 236 | | pub const MH_CORE = 0x4; /// core file |
| 237 | | pub const MH_PRELOAD = 0x5; /// preloaded executable file |
| 238 | | pub const MH_DYLIB = 0x6; /// dynamically bound shared library |
| 239 | | pub const MH_DYLINKER = 0x7; /// dynamic link editor |
| 240 | | pub const MH_BUNDLE = 0x8; /// dynamically bound bundle file |
| 241 | | pub const MH_DYLIB_STUB = 0x9; /// shared library stub for static linking only, no section contents |
| 242 | | pub const MH_DSYM = 0xa; /// companion file with only debug sections |
| 243 | | pub const MH_KEXT_BUNDLE = 0xb; /// x86_64 kexts |
| 342 | /// 64-bit segment of this file to be mapped |
| 343 | pub const LC_SEGMENT_64 = 0x19; |
| 344 | |
| 345 | /// 64-bit image routines |
| 346 | pub const LC_ROUTINES_64 = 0x1a; |
| 347 | |
| 348 | /// the uuid |
| 349 | pub const LC_UUID = 0x1b; |
| 350 | |
| 351 | /// runpath additions |
| 352 | pub const LC_RPATH = (0x1c | LC_REQ_DYLD); |
| 353 | |
| 354 | /// local of code signature |
| 355 | pub const LC_CODE_SIGNATURE = 0x1d; |
| 356 | |
| 357 | /// local of info to split segments |
| 358 | pub const LC_SEGMENT_SPLIT_INFO = 0x1e; |
| 359 | |
| 360 | /// load and re-export dylib |
| 361 | pub const LC_REEXPORT_DYLIB = (0x1f | LC_REQ_DYLD); |
| 362 | |
| 363 | /// delay load of dylib until first use |
| 364 | pub const LC_LAZY_LOAD_DYLIB = 0x20; |
| 365 | |
| 366 | /// encrypted segment information |
| 367 | pub const LC_ENCRYPTION_INFO = 0x21; |
| 368 | |
| 369 | /// compressed dyld information |
| 370 | pub const LC_DYLD_INFO = 0x22; |
| 371 | |
| 372 | /// compressed dyld information only |
| 373 | pub const LC_DYLD_INFO_ONLY = (0x22 | LC_REQ_DYLD); |
| 374 | |
| 375 | /// load upward dylib |
| 376 | pub const LC_LOAD_UPWARD_DYLIB = (0x23 | LC_REQ_DYLD); |
| 377 | |
| 378 | /// build for MacOSX min OS version |
| 379 | pub const LC_VERSION_MIN_MACOSX = 0x24; |
| 380 | |
| 381 | /// build for iPhoneOS min OS version |
| 382 | pub const LC_VERSION_MIN_IPHONEOS = 0x25; |
| 383 | |
| 384 | /// compressed table of function start addresses |
| 385 | pub const LC_FUNCTION_STARTS = 0x26; |
| 386 | |
| 387 | /// string for dyld to treat like environment variable |
| 388 | pub const LC_DYLD_ENVIRONMENT = 0x27; |
| 389 | |
| 390 | /// replacement for LC_UNIXTHREAD |
| 391 | pub const LC_MAIN = (0x28 | LC_REQ_DYLD); |
| 392 | |
| 393 | /// table of non-instructions in __text |
| 394 | pub const LC_DATA_IN_CODE = 0x29; |
| 395 | |
| 396 | /// source version used to build binary |
| 397 | pub const LC_SOURCE_VERSION = 0x2A; |
| 398 | |
| 399 | /// Code signing DRs copied from linked dylibs |
| 400 | pub const LC_DYLIB_CODE_SIGN_DRS = 0x2B; |
| 401 | |
| 402 | /// 64-bit encrypted segment information |
| 403 | pub const LC_ENCRYPTION_INFO_64 = 0x2C; |
| 404 | |
| 405 | /// linker options in MH_OBJECT files |
| 406 | pub const LC_LINKER_OPTION = 0x2D; |
| 407 | |
| 408 | /// optimization hints in MH_OBJECT files |
| 409 | pub const LC_LINKER_OPTIMIZATION_HINT = 0x2E; |
| 410 | |
| 411 | /// build for AppleTV min OS version |
| 412 | pub const LC_VERSION_MIN_TVOS = 0x2F; |
| 413 | |
| 414 | /// build for Watch min OS version |
| 415 | pub const LC_VERSION_MIN_WATCHOS = 0x30; |
| 416 | |
| 417 | /// arbitrary data included within a Mach-O file |
| 418 | pub const LC_NOTE = 0x31; |
| 419 | |
| 420 | /// build for platform min OS version |
| 421 | pub const LC_BUILD_VERSION = 0x32; |
| 422 | |
| 423 | /// the mach magic number |
| 424 | pub const MH_MAGIC = 0xfeedface; |
| 425 | |
| 426 | /// NXSwapInt(MH_MAGIC) |
| 427 | pub const MH_CIGAM = 0xcefaedfe; |
| 428 | |
| 429 | /// the 64-bit mach magic number |
| 430 | pub const MH_MAGIC_64 = 0xfeedfacf; |
| 431 | |
| 432 | /// NXSwapInt(MH_MAGIC_64) |
| 433 | pub const MH_CIGAM_64 = 0xcffaedfe; |
| 434 | |
| 435 | /// relocatable object file |
| 436 | pub const MH_OBJECT = 0x1; |
| 437 | |
| 438 | /// demand paged executable file |
| 439 | pub const MH_EXECUTE = 0x2; |
| 440 | |
| 441 | /// fixed VM shared library file |
| 442 | pub const MH_FVMLIB = 0x3; |
| 443 | |
| 444 | /// core file |
| 445 | pub const MH_CORE = 0x4; |
| 446 | |
| 447 | /// preloaded executable file |
| 448 | pub const MH_PRELOAD = 0x5; |
| 449 | |
| 450 | /// dynamically bound shared library |
| 451 | pub const MH_DYLIB = 0x6; |
| 452 | |
| 453 | /// dynamic link editor |
| 454 | pub const MH_DYLINKER = 0x7; |
| 455 | |
| 456 | /// dynamically bound bundle file |
| 457 | pub const MH_BUNDLE = 0x8; |
| 458 | |
| 459 | /// shared library stub for static linking only, no section contents |
| 460 | pub const MH_DYLIB_STUB = 0x9; |
| 461 | |
| 462 | /// companion file with only debug sections |
| 463 | pub const MH_DSYM = 0xa; |
| 464 | |
| 465 | /// x86_64 kexts |
| 466 | pub const MH_KEXT_BUNDLE = 0xb; |
| 244 | 467 | |
| 245 | 468 | // Constants for the flags field of the mach_header |
| 246 | 469 | |
| 247 | | pub const MH_NOUNDEFS = 0x1; /// the object file has no undefined references |
| 248 | | pub const MH_INCRLINK = 0x2; /// the object file is the output of an incremental link against a base file and can't be link edited again |
| 249 | | pub const MH_DYLDLINK = 0x4; /// the object file is input for the dynamic linker and can't be staticly link edited again |
| 250 | | pub const MH_BINDATLOAD = 0x8; /// the object file's undefined references are bound by the dynamic linker when loaded. |
| 251 | | pub const MH_PREBOUND = 0x10; /// the file has its dynamic undefined references prebound. |
| 252 | | pub const MH_SPLIT_SEGS = 0x20; /// the file has its read-only and read-write segments split |
| 253 | | pub const MH_LAZY_INIT = 0x40; /// the shared library init routine is to be run lazily via catching memory faults to its writeable segments (obsolete) |
| 254 | | pub const MH_TWOLEVEL = 0x80; /// the image is using two-level name space bindings |
| 255 | | pub const MH_FORCE_FLAT = 0x100; /// the executable is forcing all images to use flat name space bindings |
| 256 | | pub const MH_NOMULTIDEFS = 0x200; /// this umbrella guarantees no multiple defintions of symbols in its sub-images so the two-level namespace hints can always be used. |
| 257 | | pub const MH_NOFIXPREBINDING = 0x400; /// do not have dyld notify the prebinding agent about this executable |
| 258 | | pub const MH_PREBINDABLE = 0x800; /// the binary is not prebound but can have its prebinding redone. only used when MH_PREBOUND is not set. |
| 259 | | pub const MH_ALLMODSBOUND = 0x1000; /// indicates that this binary binds to all two-level namespace modules of its dependent libraries. only used when MH_PREBINDABLE and MH_TWOLEVEL are both set. |
| 260 | | pub const MH_SUBSECTIONS_VIA_SYMBOLS = 0x2000;/// safe to divide up the sections into sub-sections via symbols for dead code stripping |
| 261 | | pub const MH_CANONICAL = 0x4000; /// the binary has been canonicalized via the unprebind operation |
| 262 | | pub const MH_WEAK_DEFINES = 0x8000; /// the final linked image contains external weak symbols |
| 263 | | pub const MH_BINDS_TO_WEAK = 0x10000; /// the final linked image uses weak symbols |
| 264 | | |
| 265 | | pub const MH_ALLOW_STACK_EXECUTION = 0x20000;/// When this bit is set, all stacks in the task will be given stack execution privilege. Only used in MH_EXECUTE filetypes. |
| 266 | | pub const MH_ROOT_SAFE = 0x40000; /// When this bit is set, the binary declares it is safe for use in processes with uid zero |
| 267 | | |
| 268 | | pub const MH_SETUID_SAFE = 0x80000; /// When this bit is set, the binary declares it is safe for use in processes when issetugid() is true |
| 269 | | |
| 270 | | pub const MH_NO_REEXPORTED_DYLIBS = 0x100000; /// When this bit is set on a dylib, the static linker does not need to examine dependent dylibs to see if any are re-exported |
| 271 | | pub const MH_PIE = 0x200000; /// When this bit is set, the OS will load the main executable at a random address. Only used in MH_EXECUTE filetypes. |
| 272 | | pub const MH_DEAD_STRIPPABLE_DYLIB = 0x400000; /// Only for use on dylibs. When linking against a dylib that has this bit set, the static linker will automatically not create a LC_LOAD_DYLIB load command to the dylib if no symbols are being referenced from the dylib. |
| 273 | | pub const MH_HAS_TLV_DESCRIPTORS = 0x800000; /// Contains a section of type S_THREAD_LOCAL_VARIABLES |
| 274 | | |
| 275 | | pub const MH_NO_HEAP_EXECUTION = 0x1000000; /// When this bit is set, the OS will run the main executable with a non-executable heap even on platforms (e.g. i386) that don't require it. Only used in MH_EXECUTE filetypes. |
| 276 | | |
| 277 | | pub const MH_APP_EXTENSION_SAFE = 0x02000000; /// The code was linked for use in an application extension. |
| 278 | | |
| 279 | | pub const MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x04000000; /// The external symbols listed in the nlist symbol table do not include all the symbols listed in the dyld info. |
| 470 | /// the object file has no undefined references |
| 471 | pub const MH_NOUNDEFS = 0x1; |
| 472 | |
| 473 | /// the object file is the output of an incremental link against a base file and can't be link edited again |
| 474 | pub const MH_INCRLINK = 0x2; |
| 475 | |
| 476 | /// the object file is input for the dynamic linker and can't be staticly link edited again |
| 477 | pub const MH_DYLDLINK = 0x4; |
| 478 | |
| 479 | /// the object file's undefined references are bound by the dynamic linker when loaded. |
| 480 | pub const MH_BINDATLOAD = 0x8; |
| 481 | |
| 482 | /// the file has its dynamic undefined references prebound. |
| 483 | pub const MH_PREBOUND = 0x10; |
| 484 | |
| 485 | /// the file has its read-only and read-write segments split |
| 486 | pub const MH_SPLIT_SEGS = 0x20; |
| 487 | |
| 488 | /// the shared library init routine is to be run lazily via catching memory faults to its writeable segments (obsolete) |
| 489 | pub const MH_LAZY_INIT = 0x40; |
| 490 | |
| 491 | /// the image is using two-level name space bindings |
| 492 | pub const MH_TWOLEVEL = 0x80; |
| 493 | |
| 494 | /// the executable is forcing all images to use flat name space bindings |
| 495 | pub const MH_FORCE_FLAT = 0x100; |
| 496 | |
| 497 | /// this umbrella guarantees no multiple defintions of symbols in its sub-images so the two-level namespace hints can always be used. |
| 498 | pub const MH_NOMULTIDEFS = 0x200; |
| 499 | |
| 500 | /// do not have dyld notify the prebinding agent about this executable |
| 501 | pub const MH_NOFIXPREBINDING = 0x400; |
| 502 | |
| 503 | /// the binary is not prebound but can have its prebinding redone. only used when MH_PREBOUND is not set. |
| 504 | pub const MH_PREBINDABLE = 0x800; |
| 505 | |
| 506 | /// indicates that this binary binds to all two-level namespace modules of its dependent libraries. only used when MH_PREBINDABLE and MH_TWOLEVEL are both set. |
| 507 | pub const MH_ALLMODSBOUND = 0x1000; |
| 508 | |
| 509 | /// safe to divide up the sections into sub-sections via symbols for dead code stripping |
| 510 | pub const MH_SUBSECTIONS_VIA_SYMBOLS = 0x2000; |
| 511 | |
| 512 | /// the binary has been canonicalized via the unprebind operation |
| 513 | pub const MH_CANONICAL = 0x4000; |
| 514 | |
| 515 | /// the final linked image contains external weak symbols |
| 516 | pub const MH_WEAK_DEFINES = 0x8000; |
| 517 | |
| 518 | /// the final linked image uses weak symbols |
| 519 | pub const MH_BINDS_TO_WEAK = 0x10000; |
| 520 | |
| 521 | /// When this bit is set, all stacks in the task will be given stack execution privilege. Only used in MH_EXECUTE filetypes. |
| 522 | pub const MH_ALLOW_STACK_EXECUTION = 0x20000; |
| 523 | |
| 524 | /// When this bit is set, the binary declares it is safe for use in processes with uid zero |
| 525 | pub const MH_ROOT_SAFE = 0x40000; |
| 526 | |
| 527 | /// When this bit is set, the binary declares it is safe for use in processes when issetugid() is true |
| 528 | pub const MH_SETUID_SAFE = 0x80000; |
| 529 | |
| 530 | /// When this bit is set on a dylib, the static linker does not need to examine dependent dylibs to see if any are re-exported |
| 531 | pub const MH_NO_REEXPORTED_DYLIBS = 0x100000; |
| 280 | 532 | |
| 533 | /// When this bit is set, the OS will load the main executable at a random address. Only used in MH_EXECUTE filetypes. |
| 534 | pub const MH_PIE = 0x200000; |
| 535 | |
| 536 | /// Only for use on dylibs. When linking against a dylib that has this bit set, the static linker will automatically not create a LC_LOAD_DYLIB load command to the dylib if no symbols are being referenced from the dylib. |
| 537 | pub const MH_DEAD_STRIPPABLE_DYLIB = 0x400000; |
| 538 | |
| 539 | /// Contains a section of type S_THREAD_LOCAL_VARIABLES |
| 540 | pub const MH_HAS_TLV_DESCRIPTORS = 0x800000; |
| 541 | |
| 542 | /// When this bit is set, the OS will run the main executable with a non-executable heap even on platforms (e.g. i386) that don't require it. Only used in MH_EXECUTE filetypes. |
| 543 | pub const MH_NO_HEAP_EXECUTION = 0x1000000; |
| 544 | |
| 545 | /// The code was linked for use in an application extension. |
| 546 | pub const MH_APP_EXTENSION_SAFE = 0x02000000; |
| 547 | |
| 548 | /// The external symbols listed in the nlist symbol table do not include all the symbols listed in the dyld info. |
| 549 | pub const MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x04000000; |
| 281 | 550 | |
| 282 | 551 | /// The flags field of a section structure is separated into two parts a section |
| 283 | 552 | /// type and section attributes. The section types are mutually exclusive (it |
| ... | ... | @@ -285,52 +554,129 @@ pub const MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x04000000; /// The external symbol |
| 285 | 554 | /// than one attribute). |
| 286 | 555 | /// 256 section types |
| 287 | 556 | pub const SECTION_TYPE = 0x000000ff; |
| 288 | | pub const SECTION_ATTRIBUTES = 0xffffff00; /// 24 section attributes |
| 289 | | |
| 290 | | pub const S_REGULAR = 0x0; /// regular section |
| 291 | | pub const S_ZEROFILL = 0x1; /// zero fill on demand section |
| 292 | | pub const S_CSTRING_LITERALS = 0x2; /// section with only literal C string |
| 293 | | pub const S_4BYTE_LITERALS = 0x3; /// section with only 4 byte literals |
| 294 | | pub const S_8BYTE_LITERALS = 0x4; /// section with only 8 byte literals |
| 295 | | pub const S_LITERAL_POINTERS = 0x5; /// section with only pointers to |
| 296 | | |
| 297 | | |
| 298 | | pub const N_STAB = 0xe0; /// if any of these bits set, a symbolic debugging entry |
| 299 | | pub const N_PEXT = 0x10; /// private external symbol bit |
| 300 | | pub const N_TYPE = 0x0e; /// mask for the type bits |
| 301 | | pub const N_EXT = 0x01; /// external symbol bit, set for external symbols |
| 302 | | |
| 303 | | |
| 304 | | pub const N_GSYM = 0x20; /// global symbol: name,,NO_SECT,type,0 |
| 305 | | pub const N_FNAME = 0x22; /// procedure name (f77 kludge): name,,NO_SECT,0,0 |
| 306 | | pub const N_FUN = 0x24; /// procedure: name,,n_sect,linenumber,address |
| 307 | | pub const N_STSYM = 0x26; /// static symbol: name,,n_sect,type,address |
| 308 | | pub const N_LCSYM = 0x28; /// .lcomm symbol: name,,n_sect,type,address |
| 309 | | pub const N_BNSYM = 0x2e; /// begin nsect sym: 0,,n_sect,0,address |
| 310 | | pub const N_AST = 0x32; /// AST file path: name,,NO_SECT,0,0 |
| 311 | | pub const N_OPT = 0x3c; /// emitted with gcc2_compiled and in gcc source |
| 312 | | pub const N_RSYM = 0x40; /// register sym: name,,NO_SECT,type,register |
| 313 | | pub const N_SLINE = 0x44; /// src line: 0,,n_sect,linenumber,address |
| 314 | | pub const N_ENSYM = 0x4e; /// end nsect sym: 0,,n_sect,0,address |
| 315 | | pub const N_SSYM = 0x60; /// structure elt: name,,NO_SECT,type,struct_offset |
| 316 | | pub const N_SO = 0x64; /// source file name: name,,n_sect,0,address |
| 317 | | pub const N_OSO = 0x66; /// object file name: name,,0,0,st_mtime |
| 318 | | pub const N_LSYM = 0x80; /// local sym: name,,NO_SECT,type,offset |
| 319 | | pub const N_BINCL = 0x82; /// include file beginning: name,,NO_SECT,0,sum |
| 320 | | pub const N_SOL = 0x84; /// #included file name: name,,n_sect,0,address |
| 321 | | pub const N_PARAMS = 0x86; /// compiler parameters: name,,NO_SECT,0,0 |
| 322 | | pub const N_VERSION = 0x88; /// compiler version: name,,NO_SECT,0,0 |
| 323 | | pub const N_OLEVEL = 0x8A; /// compiler -O level: name,,NO_SECT,0,0 |
| 324 | | pub const N_PSYM = 0xa0; /// parameter: name,,NO_SECT,type,offset |
| 325 | | pub const N_EINCL = 0xa2; /// include file end: name,,NO_SECT,0,0 |
| 326 | | pub const N_ENTRY = 0xa4; /// alternate entry: name,,n_sect,linenumber,address |
| 327 | | pub const N_LBRAC = 0xc0; /// left bracket: 0,,NO_SECT,nesting level,address |
| 328 | | pub const N_EXCL = 0xc2; /// deleted include file: name,,NO_SECT,0,sum |
| 329 | | pub const N_RBRAC = 0xe0; /// right bracket: 0,,NO_SECT,nesting level,address |
| 330 | | pub const N_BCOMM = 0xe2; /// begin common: name,,NO_SECT,0,0 |
| 331 | | pub const N_ECOMM = 0xe4; /// end common: name,,n_sect,0,0 |
| 332 | | pub const N_ECOML = 0xe8; /// end common (local name): 0,,n_sect,0,address |
| 333 | | pub const N_LENG = 0xfe; /// second stab entry with length information |
| 557 | |
| 558 | /// 24 section attributes |
| 559 | pub const SECTION_ATTRIBUTES = 0xffffff00; |
| 560 | |
| 561 | /// regular section |
| 562 | pub const S_REGULAR = 0x0; |
| 563 | |
| 564 | /// zero fill on demand section |
| 565 | pub const S_ZEROFILL = 0x1; |
| 566 | |
| 567 | /// section with only literal C string |
| 568 | pub const S_CSTRING_LITERALS = 0x2; |
| 569 | |
| 570 | /// section with only 4 byte literals |
| 571 | pub const S_4BYTE_LITERALS = 0x3; |
| 572 | |
| 573 | /// section with only 8 byte literals |
| 574 | pub const S_8BYTE_LITERALS = 0x4; |
| 575 | |
| 576 | /// section with only pointers to |
| 577 | pub const S_LITERAL_POINTERS = 0x5; |
| 578 | |
| 579 | /// if any of these bits set, a symbolic debugging entry |
| 580 | pub const N_STAB = 0xe0; |
| 581 | |
| 582 | /// private external symbol bit |
| 583 | pub const N_PEXT = 0x10; |
| 584 | |
| 585 | /// mask for the type bits |
| 586 | pub const N_TYPE = 0x0e; |
| 587 | |
| 588 | /// external symbol bit, set for external symbols |
| 589 | pub const N_EXT = 0x01; |
| 590 | |
| 591 | /// global symbol: name,,NO_SECT,type,0 |
| 592 | pub const N_GSYM = 0x20; |
| 593 | |
| 594 | /// procedure name (f77 kludge): name,,NO_SECT,0,0 |
| 595 | pub const N_FNAME = 0x22; |
| 596 | |
| 597 | /// procedure: name,,n_sect,linenumber,address |
| 598 | pub const N_FUN = 0x24; |
| 599 | |
| 600 | /// static symbol: name,,n_sect,type,address |
| 601 | pub const N_STSYM = 0x26; |
| 602 | |
| 603 | /// .lcomm symbol: name,,n_sect,type,address |
| 604 | pub const N_LCSYM = 0x28; |
| 605 | |
| 606 | /// begin nsect sym: 0,,n_sect,0,address |
| 607 | pub const N_BNSYM = 0x2e; |
| 608 | |
| 609 | /// AST file path: name,,NO_SECT,0,0 |
| 610 | pub const N_AST = 0x32; |
| 611 | |
| 612 | /// emitted with gcc2_compiled and in gcc source |
| 613 | pub const N_OPT = 0x3c; |
| 614 | |
| 615 | /// register sym: name,,NO_SECT,type,register |
| 616 | pub const N_RSYM = 0x40; |
| 617 | |
| 618 | /// src line: 0,,n_sect,linenumber,address |
| 619 | pub const N_SLINE = 0x44; |
| 620 | |
| 621 | /// end nsect sym: 0,,n_sect,0,address |
| 622 | pub const N_ENSYM = 0x4e; |
| 623 | |
| 624 | /// structure elt: name,,NO_SECT,type,struct_offset |
| 625 | pub const N_SSYM = 0x60; |
| 626 | |
| 627 | /// source file name: name,,n_sect,0,address |
| 628 | pub const N_SO = 0x64; |
| 629 | |
| 630 | /// object file name: name,,0,0,st_mtime |
| 631 | pub const N_OSO = 0x66; |
| 632 | |
| 633 | /// local sym: name,,NO_SECT,type,offset |
| 634 | pub const N_LSYM = 0x80; |
| 635 | |
| 636 | /// include file beginning: name,,NO_SECT,0,sum |
| 637 | pub const N_BINCL = 0x82; |
| 638 | |
| 639 | /// #included file name: name,,n_sect,0,address |
| 640 | pub const N_SOL = 0x84; |
| 641 | |
| 642 | /// compiler parameters: name,,NO_SECT,0,0 |
| 643 | pub const N_PARAMS = 0x86; |
| 644 | |
| 645 | /// compiler version: name,,NO_SECT,0,0 |
| 646 | pub const N_VERSION = 0x88; |
| 647 | |
| 648 | /// compiler -O level: name,,NO_SECT,0,0 |
| 649 | pub const N_OLEVEL = 0x8A; |
| 650 | |
| 651 | /// parameter: name,,NO_SECT,type,offset |
| 652 | pub const N_PSYM = 0xa0; |
| 653 | |
| 654 | /// include file end: name,,NO_SECT,0,0 |
| 655 | pub const N_EINCL = 0xa2; |
| 656 | |
| 657 | /// alternate entry: name,,n_sect,linenumber,address |
| 658 | pub const N_ENTRY = 0xa4; |
| 659 | |
| 660 | /// left bracket: 0,,NO_SECT,nesting level,address |
| 661 | pub const N_LBRAC = 0xc0; |
| 662 | |
| 663 | /// deleted include file: name,,NO_SECT,0,sum |
| 664 | pub const N_EXCL = 0xc2; |
| 665 | |
| 666 | /// right bracket: 0,,NO_SECT,nesting level,address |
| 667 | pub const N_RBRAC = 0xe0; |
| 668 | |
| 669 | /// begin common: name,,NO_SECT,0,0 |
| 670 | pub const N_BCOMM = 0xe2; |
| 671 | |
| 672 | /// end common: name,,n_sect,0,0 |
| 673 | pub const N_ECOMM = 0xe4; |
| 674 | |
| 675 | /// end common (local name): 0,,n_sect,0,address |
| 676 | pub const N_ECOML = 0xe8; |
| 677 | |
| 678 | /// second stab entry with length information |
| 679 | pub const N_LENG = 0xfe; |
| 334 | 680 | |
| 335 | 681 | /// If a segment contains any sections marked with S_ATTR_DEBUG then all |
| 336 | 682 | /// sections in that segment must have this attribute. No section other than |
| ... | ... | @@ -339,10 +685,10 @@ pub const N_LENG = 0xfe; /// second stab entry with length information |
| 339 | 685 | /// a section type S_REGULAR. The static linker will not copy section contents |
| 340 | 686 | /// from sections with this attribute into its output file. These sections |
| 341 | 687 | /// generally contain DWARF debugging info. |
| 342 | | pub const S_ATTR_DEBUG = 0x02000000; /// a debug section |
| 688 | /// a debug section |
| 689 | pub const S_ATTR_DEBUG = 0x02000000; |
| 343 | 690 | |
| 344 | 691 | pub const cpu_type_t = integer_t; |
| 345 | 692 | pub const cpu_subtype_t = integer_t; |
| 346 | 693 | pub const integer_t = c_int; |
| 347 | 694 | pub const vm_prot_t = c_int; |
| 348 | | |