]> git.saurik.com Git - apple/system_cmds.git/blob - gcore.tproj/corefile.h
system_cmds-735.20.1.tar.gz
[apple/system_cmds.git] / gcore.tproj / corefile.h
1 /*
2 * Copyright (c) 2015 Apple Inc. All rights reserved.
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
29 extern native_mach_header_t *make_corefile_mach_header(void *);
30 extern struct proto_coreinfo_command *make_coreinfo_command(native_mach_header_t *, void *, const uuid_t, uint64_t, uint64_t);
31
32 static __inline void
33 mach_header_inc_ncmds(native_mach_header_t *mh, uint32_t inc) {
34 mh->ncmds += inc;
35 }
36
37 static __inline void
38 mach_header_inc_sizeofcmds(native_mach_header_t *mh, uint32_t inc) {
39 mh->sizeofcmds += inc;
40 }
41
42 struct size_core {
43 unsigned long count; /* number-of-objects */
44 size_t headersize; /* size in mach header */
45 mach_vm_offset_t memsize; /* size in memory */
46 };
47
48 struct size_segment_data {
49 struct size_core ssd_vanilla; /* full segments with data */
50 struct size_core ssd_sparse; /* sparse segments with data */
51 struct size_core ssd_fileref; /* full & sparse segments with file references */
52 struct size_core ssd_zfod; /* full segments with zfod pages */
53 };
54
55 struct write_segment_data {
56 task_t wsd_task;
57 native_mach_header_t *wsd_mh;
58 void *wsd_lc;
59 int wsd_fd;
60 off_t wsd_foffset;
61 off_t wsd_nwritten;
62 };
63
64 #endif /* _COREFILE_H */