From 5fd83771641d15c418f747bd343ba6738d3875f7 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sun, 9 May 2021 14:20:58 -0400 Subject: Import macOS userland adv_cmds-176 basic_cmds-55 bootstrap_cmds-116.100.1 developer_cmds-66 diskdev_cmds-667.40.1 doc_cmds-53.60.1 file_cmds-321.40.3 mail_cmds-35 misc_cmds-34 network_cmds-606.40.1 patch_cmds-17 remote_cmds-63 shell_cmds-216.60.1 system_cmds-880.60.2 text_cmds-106 --- system_cmds/gcore.tproj/corefile.h | 71 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 system_cmds/gcore.tproj/corefile.h (limited to 'system_cmds/gcore.tproj/corefile.h') diff --git a/system_cmds/gcore.tproj/corefile.h b/system_cmds/gcore.tproj/corefile.h new file mode 100644 index 0000000..2bdc43e --- /dev/null +++ b/system_cmds/gcore.tproj/corefile.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016 Apple Inc. All rights reserved. + */ + +#include "loader_additions.h" +#include "dyld_shared_cache.h" +#include "region.h" + +#include +#include +#include +#include + +#ifndef _COREFILE_H +#define _COREFILE_H + +#if defined(__LP64__) +typedef struct mach_header_64 native_mach_header_t; +typedef struct segment_command_64 native_segment_command_t; +#define NATIVE_MH_MAGIC MH_MAGIC_64 +#define NATIVE_LC_SEGMENT LC_SEGMENT_64 +#else +typedef struct mach_header native_mach_header_t; +typedef struct segment_command native_segment_command_t; +#define NATIVE_MH_MAGIC MH_MAGIC +#define NATIVE_LC_SEGMENT LC_SEGMENT +#endif + +static __inline const struct load_command *next_lc(const struct load_command *lc) { + if (lc->cmdsize && (lc->cmdsize & 3) == 0) + return (const void *)((caddr_t)lc + lc->cmdsize); + return NULL; +} + +extern native_segment_command_t *make_native_segment_command(void *, const struct vm_range *, const struct file_range *, vm_prot_t, vm_prot_t); + +extern native_mach_header_t *make_corefile_mach_header(void *); +extern struct proto_coreinfo_command *make_coreinfo_command(native_mach_header_t *, void *, const uuid_t, uint64_t, uint64_t); + +static __inline void mach_header_inc_ncmds(native_mach_header_t *mh, uint32_t inc) { + mh->ncmds += inc; +} + +static __inline void mach_header_inc_sizeofcmds(native_mach_header_t *mh, uint32_t inc) { + mh->sizeofcmds += inc; +} + +struct size_core { + unsigned long count; /* number-of-objects */ + size_t headersize; /* size in mach header */ + mach_vm_offset_t memsize; /* size in memory */ +}; + +struct size_segment_data { + struct size_core ssd_vanilla; /* full segments with data */ + struct size_core ssd_sparse; /* sparse segments with data */ + struct size_core ssd_fileref; /* full & sparse segments with uuid file references */ + struct size_core ssd_zfod; /* full segments with zfod pages */ +}; + +struct write_segment_data { + task_t wsd_task; + native_mach_header_t *wsd_mh; + void *wsd_lc; + int wsd_fd; + bool wsd_nocache; + off_t wsd_foffset; + off_t wsd_nwritten; +}; + +#endif /* _COREFILE_H */ -- cgit v1.2.3-56-ge451