]>
Commit | Line | Data |
---|---|---|
b0d623f7 A |
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_SYMTAB_H_ | |
29 | #define _KXLD_SYMTAB_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 | #include "kxld_sym.h" | |
40 | ||
41 | struct kxld_array; | |
42 | struct symtab_command; | |
43 | typedef struct kxld_symtab KXLDSymtab; | |
44 | typedef struct kxld_symtab_iterator KXLDSymtabIterator; | |
45 | ||
46 | struct kxld_symtab_iterator { | |
47 | const KXLDSymtab *symtab; | |
48 | u_int idx; | |
49 | KXLDSymPredicateTest test; | |
50 | boolean_t negate; | |
51 | }; | |
52 | ||
53 | /******************************************************************************* | |
54 | * Constructors and Destructors | |
55 | *******************************************************************************/ | |
56 | ||
57 | size_t kxld_symtab_sizeof(void) | |
58 | __attribute__((const, nonnull, visibility("hidden"))); | |
59 | ||
60 | #if KXLD_USER_OR_ILP32 | |
61 | kern_return_t kxld_symtab_init_from_macho_32(KXLDSymtab *symtab, u_char *macho, | |
62 | struct symtab_command *src, kxld_addr_t linkedit_offset) | |
63 | __attribute__((nonnull, visibility("hidden"))); | |
64 | #endif /* KXLD_USER_OR_ILP32 */ | |
65 | ||
66 | #if KXLD_USER_OR_LP64 | |
67 | kern_return_t kxld_symtab_init_from_macho_64(KXLDSymtab *symtab, u_char *macho, | |
68 | struct symtab_command *src, kxld_addr_t linkedit_offset) | |
69 | __attribute__((nonnull, visibility("hidden"))); | |
70 | #endif /* KXLD_USER_OR_ILP64 */ | |
71 | ||
72 | void kxld_symtab_iterator_init(KXLDSymtabIterator *iter, | |
73 | const KXLDSymtab *symtab, KXLDSymPredicateTest test, boolean_t negate) | |
74 | __attribute__((nonnull, visibility("hidden"))); | |
75 | ||
76 | void kxld_symtab_clear(KXLDSymtab *symtab) | |
77 | __attribute__((nonnull, visibility("hidden"))); | |
78 | ||
79 | void kxld_symtab_deinit(KXLDSymtab *symtab) | |
80 | __attribute__((nonnull, visibility("hidden"))); | |
81 | ||
82 | /******************************************************************************* | |
83 | * Accessors | |
84 | *******************************************************************************/ | |
85 | ||
86 | u_int kxld_symtab_get_num_symbols(const KXLDSymtab *symtab) | |
87 | __attribute__((pure, nonnull, visibility("hidden"))); | |
88 | ||
89 | KXLDSym * kxld_symtab_get_symbol_by_index(const KXLDSymtab *symtab, u_int idx) | |
90 | __attribute__((pure, nonnull, visibility("hidden"))); | |
91 | ||
92 | KXLDSym * kxld_symtab_get_symbol_by_name(const KXLDSymtab *symtab, | |
93 | const char *name) | |
94 | __attribute__((pure, nonnull, visibility("hidden"))); | |
95 | ||
96 | KXLDSym * kxld_symtab_get_cxx_symbol_by_value(const KXLDSymtab *symtab, | |
97 | kxld_addr_t value) | |
98 | __attribute__((pure, nonnull, visibility("hidden"))); | |
99 | ||
100 | kern_return_t kxld_symtab_get_sym_index(const KXLDSymtab *symtab, | |
101 | const KXLDSym * sym, u_int *idx) | |
102 | __attribute__((pure, nonnull, visibility("hidden"))); | |
103 | ||
104 | u_long kxld_symtab_get_macho_header_size(void) | |
105 | __attribute__((pure, visibility("hidden"))); | |
106 | ||
107 | u_long kxld_symtab_get_macho_data_size(const KXLDSymtab *symtab, | |
108 | boolean_t is_link_state, boolean_t is_32_bit) | |
109 | __attribute__((pure, nonnull, visibility("hidden"))); | |
110 | ||
111 | kern_return_t | |
112 | kxld_symtab_export_macho(const KXLDSymtab *symtab, u_char *buf, | |
113 | u_long *header_offset, u_long header_size, | |
114 | u_long *data_offset, u_long data_size, | |
115 | boolean_t is_link_state, boolean_t is_32_bit) | |
116 | __attribute__((nonnull, visibility("hidden"))); | |
117 | ||
118 | u_int kxld_symtab_iterator_get_num_remaining(const KXLDSymtabIterator *iter) | |
119 | __attribute__((pure, nonnull, visibility("hidden"))); | |
120 | ||
121 | /******************************************************************************* | |
122 | * Modifiers | |
123 | *******************************************************************************/ | |
124 | ||
125 | kern_return_t kxld_symtab_relocate(KXLDSymtab *symtab, | |
126 | const struct kxld_array *sectarray) | |
127 | __attribute__((nonnull, visibility("hidden"))); | |
128 | ||
129 | kern_return_t kxld_symtab_add_symbol(KXLDSymtab *symtab, char *name, | |
130 | kxld_addr_t link_addr, KXLDSym **symout) | |
131 | __attribute__((nonnull, visibility("hidden"))); | |
132 | ||
133 | KXLDSym * kxld_symtab_iterator_get_next(KXLDSymtabIterator *iter) | |
134 | __attribute__((nonnull, visibility("hidden"))); | |
135 | ||
136 | void kxld_symtab_iterator_reset(KXLDSymtabIterator *iter) | |
137 | __attribute__((nonnull, visibility("hidden"))); | |
138 | ||
139 | #endif /* _KXLD_SYMTAB_H_ */ | |
140 |