2 * Copyright (c) 2016 Apple Inc. All rights reserved.
5 #include "loader_additions.h"
6 #include "dyld_shared_cache.h"
9 #include <mach-o/loader.h>
10 #include <mach/mach.h>
11 #include <mach/mach_vm.h>
12 #include <sys/types.h>
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
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
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
);
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
);
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);
40 static __inline
void mach_header_inc_ncmds(native_mach_header_t
*mh
, uint32_t inc
) {
44 static __inline
void mach_header_inc_sizeofcmds(native_mach_header_t
*mh
, uint32_t inc
) {
45 mh
->sizeofcmds
+= inc
;
49 unsigned long count
; /* number-of-objects */
50 size_t headersize
; /* size in mach header */
51 mach_vm_offset_t memsize
; /* size in memory */
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 */
57 struct size_core ssd_fileref
; /* full & sparse segments with uuid file references */
58 struct size_core ssd_zfod
; /* full segments with zfod pages */
61 struct write_segment_data
{
63 native_mach_header_t
*wsd_mh
;
71 #endif /* _COREFILE_H */