diff options
author | 2021-05-09 14:20:58 -0400 | |
---|---|---|
committer | 2021-05-09 14:20:58 -0400 | |
commit | 5fd83771641d15c418f747bd343ba6738d3875f7 (patch) | |
tree | 5abf0f78f680d9837dbd93d4d4c3933bb7509599 /system_cmds/gcore.tproj/sparse.h | |
download | apple_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/sparse.h')
-rw-r--r-- | system_cmds/gcore.tproj/sparse.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/system_cmds/gcore.tproj/sparse.h b/system_cmds/gcore.tproj/sparse.h new file mode 100644 index 0000000..cf920ff --- /dev/null +++ b/system_cmds/gcore.tproj/sparse.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2016 Apple Inc. All rights reserved. + */ + +#include "region.h" +#include "dyld.h" + +#ifndef _SPARSE_H +#define _SPARSE_H + +struct subregion { + struct vm_range s_range; + native_segment_command_t s_segcmd; + const struct libent *s_libent; + bool s_isuuidref; +}; + +#define S_RANGE(s) (&(s)->s_range) + +static __inline void S_SETADDR(struct subregion *s, mach_vm_offset_t a) { + V_SETADDR(S_RANGE(s), a); +} + +static __inline void S_SETSIZE(struct subregion *s, mach_vm_offset_t sz) { + V_SETSIZE(S_RANGE(s), sz); +} + +static __inline const mach_vm_offset_t S_ADDR(const struct subregion *s) { + return V_ADDR(S_RANGE(s)); +} + +static __inline const mach_vm_offset_t S_SIZE(const struct subregion *s) { + return V_SIZE(S_RANGE(s)); +} + +static __inline const mach_vm_offset_t S_ENDADDR(const struct subregion *s) { + return S_ADDR(s) + S_SIZE(s); +} + +static __inline const char *S_MACHO_TYPE(const struct subregion *s) { + return s->s_segcmd.segname; +} + +static __inline off_t S_MACHO_FILEOFF(const struct subregion *s) { + return s->s_segcmd.fileoff; +} + +static __inline off_t S_MACHO_FILESIZE(const struct subregion *s) { + return s->s_segcmd.filesize; +} + +static __inline const struct libent *S_LIBENT(const struct subregion *s) { + return s->s_libent; +} + +static __inline const char *S_PATHNAME(const struct subregion *s) { + const struct libent *le = S_LIBENT(s); + return le ? le->le_pathname : "(unknown)"; +} + +static __inline const char *S_FILENAME(const struct subregion *s) { + const struct libent *le = S_LIBENT(s); + return le ? le->le_filename : S_PATHNAME(s); +} + +extern bool issubregiontype(const struct subregion *, const char *); + +extern walk_region_cbfn_t decorate_memory_region; +extern walk_region_cbfn_t undecorate_memory_region; +extern walk_region_cbfn_t sparse_region_optimization; + +#endif /* _SPARSE_H */ |