]> git.saurik.com Git - apple/system_cmds.git/blame - gcore.tproj/sparse.h
system_cmds-735.20.1.tar.gz
[apple/system_cmds.git] / gcore.tproj / sparse.h
CommitLineData
cf37c299
A
1/*
2 * Copyright (c) 2016 Apple Inc. All rights reserved.
3 */
4
5#include "region.h"
6#include "dyld.h"
7
8#ifndef _SPARSE_H
9#define _SPARSE_H
10
11struct subregion {
12 mach_vm_offset_t s_address;
13 mach_vm_offset_t s_size;
14 native_segment_command_t s_segcmd;
15 const struct libent *s_libent;
16 bool s_isfileref;
17};
18
19static __inline void S_SETADDR(struct subregion *s, mach_vm_offset_t a) {
20 s->s_address = a;
21}
22
23static __inline void S_SETSIZE(struct subregion *s, mach_vm_offset_t sz) {
24 s->s_size = sz;
25}
26
27static __inline const mach_vm_offset_t S_ADDR(const struct subregion *s) {
28 return s->s_address;
29}
30
31static __inline const mach_vm_offset_t S_SIZE(const struct subregion *s) {
32 return s->s_size;
33}
34
35static __inline const mach_vm_offset_t S_ENDADDR(const struct subregion *s) {
36 return S_ADDR(s) + S_SIZE(s);
37}
38
39static __inline const char *S_MACHO_TYPE(const struct subregion *s) {
40 return s->s_segcmd.segname;
41}
42
43static __inline off_t S_MACHO_FILEOFF(const struct subregion *s) {
44 return s->s_segcmd.fileoff;
45}
46
47static __inline off_t S_MACHO_FILESIZE(const struct subregion *s) {
48 return s->s_segcmd.filesize;
49}
50
51static __inline const struct libent *S_LIBENT(const struct subregion *s) {
52 return s->s_libent;
53}
54
55static __inline const char *S_PATHNAME(const struct subregion *s) {
56 const struct libent *le = S_LIBENT(s);
57 return le ? le->le_pathname : "(unknown)";
58}
59
60static __inline const char *S_FILENAME(const struct subregion *s) {
61 const struct libent *le = S_LIBENT(s);
62 return le ? le->le_filename : S_PATHNAME(s);
63}
64
65extern bool issubregiontype(const struct subregion *, const char *);
66
67extern walk_region_cbfn_t decorate_memory_region;
68extern walk_region_cbfn_t undecorate_memory_region;
69extern walk_region_cbfn_t sparse_region_optimization;
70
71#endif /* _SPARSE_H */