12
|
1 /*
|
|
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
|
|
3 *
|
|
4 * @APPLE_LICENSE_HEADER_START@
|
|
5 *
|
|
6 * This file contains Original Code and/or Modifications of Original Code
|
|
7 * as defined in and that are subject to the Apple Public Source License
|
|
8 * Version 2.0 (the 'License'). You may not use this file except in
|
|
9 * compliance with the License. Please obtain a copy of the License at
|
|
10 * http://www.opensource.apple.com/apsl/ and read it before using this
|
|
11 * file.
|
|
12 *
|
|
13 * The Original Code and all software distributed under the License are
|
|
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
|
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
|
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
|
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
|
18 * Please see the License for the specific language governing rights and
|
|
19 * limitations under the License.
|
|
20 *
|
|
21 * @APPLE_LICENSE_HEADER_END@
|
|
22 */
|
|
23 #ifndef _MACH_O_GETSECT_H_
|
|
24 #define _MACH_O_GETSECT_H_
|
|
25
|
|
26 #include <stdint.h>
|
|
27 #include <mach-o/loader.h>
|
|
28
|
|
29 #if __cplusplus
|
|
30 extern "C" {
|
|
31 #endif /* __cplusplus */
|
|
32
|
|
33 /*
|
|
34 * Runtime interfaces for Mach-O programs. For both 32-bit and 64-bit programs,
|
|
35 * where the sizes returned will be 32-bit or 64-bit based on the size of
|
|
36 * 'unsigned long'.
|
|
37 */
|
|
38 extern char *getsectdata(
|
|
39 const char *segname,
|
|
40 const char *sectname,
|
|
41 unsigned long *size);
|
|
42
|
|
43 extern char *getsectdatafromFramework(
|
|
44 const char *FrameworkName,
|
|
45 const char *segname,
|
|
46 const char *sectname,
|
|
47 unsigned long *size);
|
|
48
|
|
49 extern unsigned long get_end(void);
|
|
50 extern unsigned long get_etext(void);
|
|
51 extern unsigned long get_edata(void);
|
|
52
|
|
53 #ifndef __LP64__
|
|
54 /*
|
|
55 * Runtime interfaces for 32-bit Mach-O programs.
|
|
56 */
|
|
57 extern const struct section *getsectbyname(
|
|
58 const char *segname,
|
|
59 const char *sectname);
|
|
60
|
|
61 extern uint8_t *getsectiondata(
|
|
62 const struct mach_header *mhp,
|
|
63 const char *segname,
|
|
64 const char *sectname,
|
|
65 unsigned long *size);
|
|
66
|
|
67 extern const struct segment_command *getsegbyname(
|
|
68 const char *segname);
|
|
69
|
|
70 extern uint8_t *getsegmentdata(
|
|
71 const struct mach_header *mhp,
|
|
72 const char *segname,
|
|
73 unsigned long *size);
|
|
74
|
|
75 #else /* defined(__LP64__) */
|
|
76 /*
|
|
77 * Runtime interfaces for 64-bit Mach-O programs.
|
|
78 */
|
|
79 extern const struct section_64 *getsectbyname(
|
|
80 const char *segname,
|
|
81 const char *sectname);
|
|
82
|
|
83 extern uint8_t *getsectiondata(
|
|
84 const struct mach_header_64 *mhp,
|
|
85 const char *segname,
|
|
86 const char *sectname,
|
|
87 unsigned long *size);
|
|
88
|
|
89 extern const struct segment_command_64 *getsegbyname(
|
|
90 const char *segname);
|
|
91
|
|
92 extern uint8_t *getsegmentdata(
|
|
93 const struct mach_header_64 *mhp,
|
|
94 const char *segname,
|
|
95 unsigned long *size);
|
|
96
|
|
97 #endif /* defined(__LP64__) */
|
|
98
|
|
99 /*
|
|
100 * Interfaces for tools working with 32-bit Mach-O files.
|
|
101 */
|
|
102 extern char *getsectdatafromheader(
|
|
103 const struct mach_header *mhp,
|
|
104 const char *segname,
|
|
105 const char *sectname,
|
|
106 uint32_t *size);
|
|
107
|
|
108 extern const struct section *getsectbynamefromheader(
|
|
109 const struct mach_header *mhp,
|
|
110 const char *segname,
|
|
111 const char *sectname);
|
|
112
|
|
113 /*
|
|
114 * Interfaces for tools working with 64-bit Mach-O files.
|
|
115 */
|
|
116 extern char *getsectdatafromheader_64(
|
|
117 const struct mach_header_64 *mhp,
|
|
118 const char *segname,
|
|
119 const char *sectname,
|
|
120 uint64_t *size);
|
|
121
|
|
122 extern const struct section_64 *getsectbynamefromheader_64(
|
|
123 const struct mach_header_64 *mhp,
|
|
124 const char *segname,
|
|
125 const char *sectname);
|
|
126
|
|
127 #if __cplusplus
|
|
128 }
|
|
129 #endif /* __cplusplus */
|
|
130
|
|
131 #endif /* _MACH_O_GETSECT_H_ */
|