]> git.saurik.com Git - apple/xnu.git/blob - libkern/kxld/kxld_kext.h
xnu-1456.1.26.tar.gz
[apple/xnu.git] / libkern / kxld / kxld_kext.h
1 /*
2 * Copyright (c) 2008 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 #ifndef _KXLD_KEXT_H_
29 #define _KXLD_KEXT_H_
30
31 #include <mach/machine.h>
32 #include <sys/types.h>
33 #if KERNEL
34 #include <libkern/kxld_types.h>
35 #else
36 #include "kxld_types.h"
37 #endif
38
39 struct kxld_array;
40 struct kxld_kext;
41 struct kxld_dict;
42 struct kxld_sect;
43 struct kxld_seg;
44 struct kxld_symtab;
45 struct kxld_vtable;
46 typedef struct kxld_kext KXLDKext;
47
48 /*******************************************************************************
49 * Constructors and Destructors
50 *******************************************************************************/
51
52 size_t kxld_kext_sizeof(void)
53 __attribute__((const, nonnull, visibility("hidden")));
54
55 kern_return_t kxld_kext_init(KXLDKext *kext, u_char *file, u_long size,
56 const char *name, KXLDFlags flags, boolean_t is_kernel, KXLDArray *seg_order,
57 cpu_type_t cputype, cpu_subtype_t cpusubtype)
58 __attribute__((nonnull(1,2,4), visibility("hidden")));
59
60 void kxld_kext_clear(KXLDKext *kext)
61 __attribute__((nonnull, visibility("hidden")));
62
63 void kxld_kext_deinit(KXLDKext *kext)
64 __attribute__((nonnull, visibility("hidden")));
65
66 /*******************************************************************************
67 * Accessors
68 *******************************************************************************/
69
70 boolean_t kxld_kext_is_true_kext(const KXLDKext *kext)
71 __attribute__((pure, nonnull, visibility("hidden")));
72
73 boolean_t kxld_kext_is_32_bit(const KXLDKext *kext)
74 __attribute__((pure, nonnull, visibility("hidden")));
75
76 void kxld_kext_get_cputype(const KXLDKext *kext, cpu_type_t *cputype,
77 cpu_subtype_t *cpusubtype)
78 __attribute__((nonnull, visibility("hidden")));
79
80 kern_return_t kxld_kext_validate_cputype(const KXLDKext *kext, cpu_type_t cputype,
81 cpu_subtype_t cpusubtype)
82 __attribute__((pure, nonnull, visibility("hidden")));
83
84 void kxld_kext_get_vmsize(const KXLDKext *kext, u_long *header_size,
85 u_long *vmsize)
86 __attribute__((nonnull, visibility("hidden")));
87
88 const struct kxld_symtab * kxld_kext_get_symtab(const KXLDKext *kext)
89 __attribute__((pure, nonnull, visibility("hidden")));
90
91 u_int kxld_kext_get_num_symbols(const KXLDKext *kext)
92 __attribute__((pure, nonnull, visibility("hidden")));
93
94 void kxld_kext_get_vtables(KXLDKext *kext, const struct kxld_array **vtables)
95 __attribute__((nonnull, visibility("hidden")));
96
97 u_int kxld_kext_get_num_vtables(const KXLDKext *kext)
98 __attribute__((pure, nonnull, visibility("hidden")));
99
100 struct kxld_seg * kxld_kext_get_seg_by_name(const KXLDKext *kext,
101 const char *segname)
102 __attribute__((pure, nonnull, visibility("hidden")));
103
104 struct kxld_sect * kxld_kext_get_sect_by_name(const KXLDKext *kext,
105 const char *segname, const char *sectname)
106 __attribute__((pure, nonnull, visibility("hidden")));
107
108 int kxld_kext_get_sectnum_for_sect(const KXLDKext *kext,
109 const struct kxld_sect *sect)
110 __attribute__((pure, nonnull, visibility("hidden")));
111
112 const struct kxld_array * kxld_kext_get_section_order(const KXLDKext *kext)
113 __attribute__((pure, nonnull, visibility("hidden")));
114
115 /* This will be the same size as kxld_kext_get_vmsize */
116 kern_return_t kxld_kext_export_linked_object(const KXLDKext *kext,
117 u_char *linked_object, kxld_addr_t *kmod_info_kern)
118 __attribute__((nonnull, visibility("hidden")));
119
120 #if !KERNEL
121 kern_return_t kxld_kext_export_symbol_file(const KXLDKext *kext,
122 u_char **symbol_file, u_long *filesize)
123 __attribute__((nonnull, visibility("hidden")));
124 #endif
125
126 boolean_t kxld_kext_target_needs_swap(const KXLDKext *kext)
127 __attribute__((pure, nonnull, visibility("hidden")));
128
129 /*******************************************************************************
130 * Modifiers
131 *******************************************************************************/
132
133 kern_return_t kxld_kext_resolve(KXLDKext *kext, struct kxld_dict *patched_vtables,
134 struct kxld_dict *defined_symbols)
135 __attribute__((nonnull, visibility("hidden")));
136
137 kern_return_t kxld_kext_relocate(KXLDKext *kext, kxld_addr_t link_address,
138 struct kxld_dict *patched_vtables, struct kxld_dict *defined_symbols,
139 struct kxld_dict *obsolete_symbols)
140 __attribute__((nonnull(1,3,4), visibility("hidden")));
141
142 #endif /* _KXLD_KEXT_H_ */