]>
Commit | Line | Data |
---|---|---|
cf37c299 | 1 | /* |
887d5eed | 2 | * Copyright (c) 2016 Apple Inc. All rights reserved. |
cf37c299 A |
3 | */ |
4 | ||
5 | #include "loader_additions.h" | |
6 | #include "dyld_shared_cache.h" | |
7 | #include "region.h" | |
8 | ||
9 | #include <mach-o/loader.h> | |
10 | #include <mach/mach.h> | |
11 | #include <mach/mach_vm.h> | |
12 | #include <sys/types.h> | |
13 | ||
14 | #ifndef _COREFILE_H | |
15 | #define _COREFILE_H | |
16 | ||
17 | #if defined(__LP64__) | |
18 | typedef struct mach_header_64 native_mach_header_t; | |
19 | typedef struct segment_command_64 native_segment_command_t; | |
20 | #define NATIVE_MH_MAGIC MH_MAGIC_64 | |
21 | #define NATIVE_LC_SEGMENT LC_SEGMENT_64 | |
22 | #else | |
23 | typedef struct mach_header native_mach_header_t; | |
24 | typedef struct segment_command native_segment_command_t; | |
25 | #define NATIVE_MH_MAGIC MH_MAGIC | |
26 | #define NATIVE_LC_SEGMENT LC_SEGMENT | |
27 | #endif | |
28 | ||
887d5eed A |
29 | static __inline const struct load_command *next_lc(const struct load_command *lc) { |
30 | if (lc->cmdsize && (lc->cmdsize & 3) == 0) | |
31 | return (const void *)((caddr_t)lc + lc->cmdsize); | |
32 | return NULL; | |
33 | } | |
34 | ||
35 | extern native_segment_command_t *make_native_segment_command(void *, const struct vm_range *, const struct file_range *, vm_prot_t, vm_prot_t); | |
36 | ||
cf37c299 A |
37 | extern native_mach_header_t *make_corefile_mach_header(void *); |
38 | extern struct proto_coreinfo_command *make_coreinfo_command(native_mach_header_t *, void *, const uuid_t, uint64_t, uint64_t); | |
39 | ||
887d5eed | 40 | static __inline void mach_header_inc_ncmds(native_mach_header_t *mh, uint32_t inc) { |
cf37c299 A |
41 | mh->ncmds += inc; |
42 | } | |
43 | ||
887d5eed | 44 | static __inline void mach_header_inc_sizeofcmds(native_mach_header_t *mh, uint32_t inc) { |
cf37c299 A |
45 | mh->sizeofcmds += inc; |
46 | } | |
47 | ||
48 | struct size_core { | |
49 | unsigned long count; /* number-of-objects */ | |
50 | size_t headersize; /* size in mach header */ | |
51 | mach_vm_offset_t memsize; /* size in memory */ | |
52 | }; | |
53 | ||
54 | struct size_segment_data { | |
55 | struct size_core ssd_vanilla; /* full segments with data */ | |
56 | struct size_core ssd_sparse; /* sparse segments with data */ | |
887d5eed | 57 | struct size_core ssd_fileref; /* full & sparse segments with uuid file references */ |
cf37c299 A |
58 | struct size_core ssd_zfod; /* full segments with zfod pages */ |
59 | }; | |
60 | ||
61 | struct write_segment_data { | |
62 | task_t wsd_task; | |
63 | native_mach_header_t *wsd_mh; | |
64 | void *wsd_lc; | |
65 | int wsd_fd; | |
887d5eed | 66 | bool wsd_nocache; |
cf37c299 A |
67 | off_t wsd_foffset; |
68 | off_t wsd_nwritten; | |
69 | }; | |
70 | ||
71 | #endif /* _COREFILE_H */ |