]>
git.cameronkatri.com Git - apple_cmds.git/blob - system_cmds/gcore.tproj/loader_additions.h
2 * Copyright (c) 2015 Apple Inc. All rights reserved.
5 #include <mach-o/loader.h>
7 #ifndef _LOADER_ADDITIONS_H
8 #define _LOADER_ADDITIONS_H
11 * Something like this should end up in <mach-o/loader.h>
14 #define proto_LC_COREINFO 0x140 /* unofficial value!! */
16 #define proto_CORETYPE_KERNEL 1
17 #define proto_CORETYPE_USER 2
18 #define proto_CORETYPE_IBOOT 3
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 */
24 uint16_t type
; /* CORETYPE_KERNEL, CORETYPE_USER etc. */
25 uint16_t pageshift
; /* log2 host pagesize */
26 /* content & interpretation depends on 'type' field */
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 */
32 #define proto_LC_FILEREF 0x141 /* unofficial value! */
34 #define FREF_ID_SHIFT 0
35 #define FREF_ID_MASK 0x7 /* up to 8 flavors */
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? */
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)
47 struct proto_fileref_command
{
48 uint32_t cmd
; /* LC_FILEREF */
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 */
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 */
65 #define proto_LC_COREDATA 0x142 /* unofficial value! */
68 * These are flag bits for the segment_command 'flags' field.
71 #define COMP_ALG_MASK 0x7
72 /* carve out 3 bits for an enum i.e. allow for 7 flavors */
73 #define COMP_ALG_SHIFT 4 /* (bottom 4 bits taken) */
75 /* zero -> no compression */
78 kCOMP_LZ4
= 1, /* 0x100 */
79 kCOMP_ZLIB
= 2, /* 0x205 */
80 kCOMP_LZMA
= 3, /* 0x306 */
81 kCOMP_LZFSE
= 4, /* 0x801 */
82 } compression_flavor_t
;
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)
87 struct proto_coredata_command
{
88 uint32_t cmd
; /* LC_COREDATA */
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 */
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 */
103 #endif /* _LOADER_ADDITIONS_H */