]>
Commit | Line | Data |
---|---|---|
cf37c299 A |
1 | /* |
2 | * Copyright (c) 2015 Apple Inc. All rights reserved. | |
3 | */ | |
4 | ||
5 | #include <mach-o/loader.h> | |
6 | ||
7 | #ifndef _LOADER_ADDITIONS_H | |
8 | #define _LOADER_ADDITIONS_H | |
9 | ||
10 | /* | |
11 | * Something like this should end up in <mach-o/loader.h> | |
12 | */ | |
13 | #define proto_LC_COREINFO 0x40 /* unofficial value!! */ | |
14 | ||
15 | #define proto_CORETYPE_KERNEL 1 | |
16 | #define proto_CORETYPE_USER 2 | |
17 | #define proto_CORETYPE_IBOOT 3 | |
18 | ||
19 | struct proto_coreinfo_command { | |
20 | uint32_t cmd; /* LC_COREINFO */ | |
21 | uint32_t cmdsize; /* total size of this command */ | |
22 | uint32_t version; /* currently 1 */ | |
23 | /* | |
24 | * 'type' determines the content of the corefile; interpretation | |
25 | * of the address and uuid fields are specific to the type. | |
26 | */ | |
27 | uint32_t type; /* CORETYPE_KERNEL, CORETYPE_USER etc. */ | |
28 | uint64_t address; /* load address of "main binary" */ | |
29 | uint8_t uuid[16]; /* uuid of "main binary" */ | |
30 | uint64_t dyninfo; /* dynamic modules info */ | |
31 | }; | |
32 | ||
33 | /* | |
34 | * These are flag bits for the segment_command 'flags' field. | |
35 | */ | |
36 | ||
37 | #define proto_SG_COMP_ALG_MASK 0x7 | |
38 | /* carve out 3 bits for an enum i.e. allow for 7 flavors */ | |
39 | #define proto_SG_COMP_ALG_SHIFT 4 /* (bottom 4 bits taken) */ | |
40 | ||
41 | /* zero -> no compression */ | |
42 | #define proto_SG_COMP_LZ4 1 /* 0x100 */ | |
43 | #define proto_SG_COMP_ZLIB 2 /* 0x205 */ | |
44 | #define proto_SG_COMP_LZMA 3 /* 0x306 */ | |
45 | #define proto_SG_COMP_LZFSE 4 /* 0x801 */ | |
46 | ||
47 | #define proto_SG_COMP_ALG_TYPE(flags) (((flags) >> proto_SG_COMP_ALG_SHIFT) & proto_SG_COMP_ALG_MASK) | |
48 | #define proto_SG_COMP_MAKE_FLAGS(type) (((type) & proto_SG_COMP_ALG_MASK) << proto_SG_COMP_ALG_SHIFT) | |
49 | ||
50 | #define proto_LC_FILEREF 0x41 /* unofficial value! */ | |
51 | ||
52 | struct proto_fileref_command { | |
53 | uint32_t cmd; /* LC_FILEREF */ | |
54 | uint32_t cmdsize; | |
55 | union lc_str filename; /* filename these bits come from */ | |
56 | uint8_t uuid[16]; /* uuid if known */ | |
57 | uint64_t vmaddr; /* memory address of this segment */ | |
58 | uint64_t vmsize; /* memory size of this segment */ | |
59 | uint64_t fileoff; /* file offset of this segment */ | |
60 | uint64_t filesize; /* amount to map from the file */ | |
61 | vm_prot_t maxprot; /* maximum VM protection */ | |
62 | vm_prot_t initprot; /* initial VM protection */ | |
63 | }; | |
64 | ||
65 | #endif /* _LOADER_ADDITIONS_H */ |