]> git.saurik.com Git - apple/xnu.git/blob - libkern/kxld/kxld_object.h
xnu-1699.22.73.tar.gz
[apple/xnu.git] / libkern / kxld / kxld_object.h
1 /*
2 * Copyright (c) 2009 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_OBJECT_H_
29 #define _KXLD_OBJECT_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_dict;
41 struct kxld_reloc;
42 struct kxld_relocator;
43 struct kxld_sect;
44 struct kxld_sym;
45 struct kxld_symtab;
46
47 typedef struct kxld_object KXLDObject;
48
49 /*******************************************************************************
50 * Constructors and destructors
51 *******************************************************************************/
52
53 size_t kxld_object_sizeof(void)
54 __attribute__((const, visibility("hidden")));
55
56 kern_return_t kxld_object_init_from_macho(KXLDObject *object,
57 u_char *file, u_long size, const char *name,
58 struct kxld_array *section_order,
59 cpu_type_t cputype, cpu_subtype_t cpusubtype)
60 __attribute__((nonnull(1,2,4) visibility("hidden")));
61
62 void kxld_object_clear(KXLDObject *object)
63 __attribute__((nonnull, visibility("hidden")));
64
65 void kxld_object_deinit(KXLDObject *object)
66 __attribute__((nonnull, visibility("hidden")));
67
68 /*******************************************************************************
69 * Accessors
70 *******************************************************************************/
71
72 const u_char * kxld_object_get_file(const KXLDObject *object)
73 __attribute__((pure, nonnull, visibility("hidden")));
74
75 const char * kxld_object_get_name(const KXLDObject *object)
76 __attribute__((pure, nonnull, visibility("hidden")));
77
78 boolean_t kxld_object_is_32_bit(const KXLDObject *object)
79 __attribute__((pure, nonnull, visibility("hidden")));
80
81 boolean_t kxld_object_is_final_image(const KXLDObject *object)
82 __attribute__((pure, nonnull, visibility("hidden")));
83
84 boolean_t kxld_object_is_kernel(const KXLDObject *object)
85 __attribute__((pure, nonnull, visibility("hidden")));
86
87 boolean_t kxld_object_is_linked(const KXLDObject *object)
88 __attribute__((pure, nonnull, visibility("hidden")));
89
90 boolean_t kxld_object_target_supports_strict_patching(const KXLDObject *object)
91 __attribute__((pure, nonnull, visibility("hidden")));
92
93 boolean_t kxld_object_target_supports_common_symbols(const KXLDObject *object)
94 __attribute__((pure, nonnull, visibility("hidden")));
95
96 const struct kxld_relocator * kxld_object_get_relocator(
97 const KXLDObject * object)
98 __attribute__((pure, nonnull, visibility("hidden")));
99
100 const struct kxld_reloc * kxld_object_get_reloc_at_symbol(
101 const KXLDObject *object, const struct kxld_sym *sym)
102 __attribute__((pure, nonnull, visibility("hidden")));
103
104 const struct kxld_sym * kxld_object_get_symbol_of_reloc(
105 const KXLDObject *object, const struct kxld_reloc *reloc,
106 const struct kxld_sect *sect)
107 __attribute__((pure, nonnull, visibility("hidden")));
108
109 const struct kxld_sect * kxld_object_get_section_by_index(
110 const KXLDObject *object, u_int sectnum)
111 __attribute__((pure, nonnull, visibility("hidden")));
112
113 const struct kxld_array * kxld_object_get_extrelocs(
114 const KXLDObject *object)
115 __attribute__((pure, nonnull, visibility("hidden")));
116
117 const struct kxld_symtab * kxld_object_get_symtab(const KXLDObject *object)
118 __attribute__((pure, nonnull, visibility("hidden")));
119
120 void kxld_object_get_vmsize(const KXLDObject *object, u_long *header_size,
121 u_long *vmsize)
122 __attribute__((nonnull, visibility("hidden")));
123
124 /* This will be the same size as kxld_kext_get_vmsize */
125 kern_return_t kxld_object_export_linked_object(const KXLDObject *object,
126 u_char *linked_object)
127 __attribute__((nonnull, visibility("hidden")));
128
129 /*******************************************************************************
130 * Modifiers
131 *******************************************************************************/
132
133 kern_return_t kxld_object_index_symbols_by_name(KXLDObject *object)
134 __attribute__((nonnull, visibility("hidden")));
135
136 kern_return_t kxld_object_index_cxx_symbols_by_value(KXLDObject *object)
137 __attribute__((nonnull, visibility("hidden")));
138
139 kern_return_t kxld_object_relocate(KXLDObject *object, kxld_addr_t link_address)
140 __attribute__((nonnull, visibility("hidden")));
141
142 kern_return_t kxld_object_resolve_symbol(KXLDObject *object,
143 const struct kxld_sym *sym, kxld_addr_t addr)
144 __attribute__((nonnull, visibility("hidden")));
145
146 kern_return_t kxld_object_patch_symbol(KXLDObject *object,
147 const struct kxld_sym *sym)
148 __attribute__((nonnull, visibility("hidden")));
149
150 kern_return_t kxld_object_add_symbol(KXLDObject *object, char *name,
151 kxld_addr_t link_addr, const struct kxld_sym **sym_out)
152 __attribute__((nonnull, visibility("hidden")));
153
154 kern_return_t kxld_object_process_relocations(KXLDObject *object,
155 const struct kxld_dict *patched_vtables)
156 __attribute__((nonnull, visibility("hidden")));
157
158 #endif /* _KXLD_OBJECT_H_ */
159