]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | struct 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 | ||
19 | static __inline void S_SETADDR(struct subregion *s, mach_vm_offset_t a) { | |
20 | s->s_address = a; | |
21 | } | |
22 | ||
23 | static __inline void S_SETSIZE(struct subregion *s, mach_vm_offset_t sz) { | |
24 | s->s_size = sz; | |
25 | } | |
26 | ||
27 | static __inline const mach_vm_offset_t S_ADDR(const struct subregion *s) { | |
28 | return s->s_address; | |
29 | } | |
30 | ||
31 | static __inline const mach_vm_offset_t S_SIZE(const struct subregion *s) { | |
32 | return s->s_size; | |
33 | } | |
34 | ||
35 | static __inline const mach_vm_offset_t S_ENDADDR(const struct subregion *s) { | |
36 | return S_ADDR(s) + S_SIZE(s); | |
37 | } | |
38 | ||
39 | static __inline const char *S_MACHO_TYPE(const struct subregion *s) { | |
40 | return s->s_segcmd.segname; | |
41 | } | |
42 | ||
43 | static __inline off_t S_MACHO_FILEOFF(const struct subregion *s) { | |
44 | return s->s_segcmd.fileoff; | |
45 | } | |
46 | ||
47 | static __inline off_t S_MACHO_FILESIZE(const struct subregion *s) { | |
48 | return s->s_segcmd.filesize; | |
49 | } | |
50 | ||
51 | static __inline const struct libent *S_LIBENT(const struct subregion *s) { | |
52 | return s->s_libent; | |
53 | } | |
54 | ||
55 | static __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 | ||
60 | static __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 | ||
65 | extern bool issubregiontype(const struct subregion *, const char *); | |
66 | ||
67 | extern walk_region_cbfn_t decorate_memory_region; | |
68 | extern walk_region_cbfn_t undecorate_memory_region; | |
69 | extern walk_region_cbfn_t sparse_region_optimization; | |
70 | ||
71 | #endif /* _SPARSE_H */ |