aboutsummaryrefslogtreecommitdiffstats
path: root/system_cmds/gcore.tproj/corefile.h
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2021-05-09 14:20:58 -0400
committerCameron Katri <me@cameronkatri.com>2021-05-09 14:20:58 -0400
commit5fd83771641d15c418f747bd343ba6738d3875f7 (patch)
tree5abf0f78f680d9837dbd93d4d4c3933bb7509599 /system_cmds/gcore.tproj/corefile.h
downloadapple_cmds-5fd83771641d15c418f747bd343ba6738d3875f7.tar.gz
apple_cmds-5fd83771641d15c418f747bd343ba6738d3875f7.tar.zst
apple_cmds-5fd83771641d15c418f747bd343ba6738d3875f7.zip
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
Diffstat (limited to 'system_cmds/gcore.tproj/corefile.h')
-rw-r--r--system_cmds/gcore.tproj/corefile.h71
1 files changed, 71 insertions, 0 deletions
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 <mach-o/loader.h>
+#include <mach/mach.h>
+#include <mach/mach_vm.h>
+#include <sys/types.h>
+
+#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 */