]>
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 | */ | |
887d5eed A |
13 | |
14 | #define proto_LC_COREINFO 0x140 /* unofficial value!! */ | |
cf37c299 A |
15 | |
16 | #define proto_CORETYPE_KERNEL 1 | |
887d5eed | 17 | #define proto_CORETYPE_USER 2 |
cf37c299 A |
18 | #define proto_CORETYPE_IBOOT 3 |
19 | ||
20 | struct proto_coreinfo_command { | |
21 | uint32_t cmd; /* LC_COREINFO */ | |
22 | uint32_t cmdsize; /* total size of this command */ | |
23 | uint32_t version; /* currently 1 */ | |
887d5eed A |
24 | uint16_t type; /* CORETYPE_KERNEL, CORETYPE_USER etc. */ |
25 | uint16_t pageshift; /* log2 host pagesize */ | |
26 | /* content & interpretation depends on 'type' field */ | |
cf37c299 A |
27 | uint64_t address; /* load address of "main binary" */ |
28 | uint8_t uuid[16]; /* uuid of "main binary" */ | |
29 | uint64_t dyninfo; /* dynamic modules info */ | |
30 | }; | |
31 | ||
887d5eed A |
32 | #define proto_LC_FILEREF 0x141 /* unofficial value! */ |
33 | ||
34 | #define FREF_ID_SHIFT 0 | |
35 | #define FREF_ID_MASK 0x7 /* up to 8 flavors */ | |
36 | ||
37 | typedef enum { | |
38 | kFREF_ID_NONE = 0, /* file has no available verifying ID */ | |
39 | kFREF_ID_UUID = 1, /* file has an associated UUID */ | |
40 | kFREF_ID_MTIMESPEC_LE = 2, /* file has a specific mtime */ | |
41 | /* one day: file has a computed hash? */ | |
42 | } fref_type_t; | |
43 | ||
44 | #define FREF_ID_TYPE(f) ((fref_type_t)(((f) >> FREF_ID_SHIFT) & FREF_ID_MASK)) | |
45 | #define FREF_MAKE_FLAGS(t) (((t) & FREF_ID_MASK) << FREF_ID_SHIFT) | |
46 | ||
47 | struct proto_fileref_command { | |
48 | uint32_t cmd; /* LC_FILEREF */ | |
49 | uint32_t cmdsize; | |
50 | union lc_str filename; /* filename these bits come from */ | |
51 | uint8_t id[16]; /* uuid, size or hash etc. */ | |
52 | uint64_t vmaddr; /* memory address of this segment */ | |
53 | uint64_t vmsize; /* memory size of this segment */ | |
54 | uint64_t fileoff; /* file offset of this segment */ | |
55 | uint64_t filesize; /* amount to map from the file */ | |
56 | vm_prot_t maxprot; /* maximum VM protection */ | |
57 | vm_prot_t prot; /* current VM protection */ | |
58 | uint32_t flags; | |
59 | uint8_t share_mode; /* SM_COW etc. */ | |
60 | uint8_t purgable; /* VM_PURGABLE_NONVOLATILE etc. */ | |
61 | uint8_t tag; /* VM_MEMORY_MALLOC etc. */ | |
62 | uint8_t extp; /* external pager */ | |
63 | }; | |
64 | ||
65 | #define proto_LC_COREDATA 0x142 /* unofficial value! */ | |
66 | ||
cf37c299 A |
67 | /* |
68 | * These are flag bits for the segment_command 'flags' field. | |
69 | */ | |
70 | ||
887d5eed | 71 | #define COMP_ALG_MASK 0x7 |
cf37c299 | 72 | /* carve out 3 bits for an enum i.e. allow for 7 flavors */ |
887d5eed | 73 | #define COMP_ALG_SHIFT 4 /* (bottom 4 bits taken) */ |
cf37c299 A |
74 | |
75 | /* zero -> no compression */ | |
887d5eed A |
76 | typedef enum { |
77 | kCOMP_NONE = 0, | |
78 | kCOMP_LZ4 = 1, /* 0x100 */ | |
79 | kCOMP_ZLIB = 2, /* 0x205 */ | |
80 | kCOMP_LZMA = 3, /* 0x306 */ | |
81 | kCOMP_LZFSE = 4, /* 0x801 */ | |
82 | } compression_flavor_t; | |
cf37c299 | 83 | |
887d5eed A |
84 | #define COMP_ALG_TYPE(f) ((compression_flavor_t)((f) >> COMP_ALG_SHIFT) & COMP_ALG_MASK) |
85 | #define COMP_MAKE_FLAGS(t) (((t) & COMP_ALG_MASK) << COMP_ALG_SHIFT) | |
cf37c299 | 86 | |
887d5eed A |
87 | struct proto_coredata_command { |
88 | uint32_t cmd; /* LC_COREDATA */ | |
cf37c299 | 89 | uint32_t cmdsize; |
887d5eed A |
90 | uint64_t vmaddr; /* memory address of this segment */ |
91 | uint64_t vmsize; /* memory size of this segment */ | |
92 | uint64_t fileoff; /* file offset of this segment */ | |
93 | uint64_t filesize; /* amount to map from the file */ | |
94 | vm_prot_t maxprot; /* maximum VM protection */ | |
95 | vm_prot_t prot; /* current VM protection */ | |
96 | uint32_t flags; | |
97 | uint8_t share_mode; /* SM_COW etc. */ | |
98 | uint8_t purgable; /* VM_PURGABLE_NONVOLATILE etc. */ | |
99 | uint8_t tag; /* VM_MEMORY_MALLOC etc. */ | |
100 | uint8_t extp; /* external pager */ | |
cf37c299 A |
101 | }; |
102 | ||
103 | #endif /* _LOADER_ADDITIONS_H */ |