2 * Copyright (c) 2008 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 #ifndef _KXLD_SYMTAB_H_
29 #define _KXLD_SYMTAB_H_
31 #include <mach/machine.h>
32 #include <sys/types.h>
34 #include <libkern/kxld_types.h>
36 #include "kxld_types.h"
43 struct symtab_command
;
44 typedef struct kxld_symtab KXLDSymtab
;
45 typedef struct kxld_symtab_iterator KXLDSymtabIterator
;
47 struct kxld_symtab_iterator
{
48 const KXLDSymtab
*symtab
;
50 KXLDSymPredicateTest test
;
54 /*******************************************************************************
55 * Constructors and Destructors
56 *******************************************************************************/
58 size_t kxld_symtab_sizeof(void)
59 __attribute__((const, visibility("hidden")));
61 #if KXLD_USER_OR_ILP32
62 kern_return_t
kxld_symtab_init_from_macho_32(KXLDSymtab
*symtab
,
63 struct symtab_command
*src
, u_char
*macho
, KXLDSeg
* kernel_linkedit_seg
)
64 __attribute__((nonnull(1,2), visibility("hidden")));
65 #endif /* KXLD_USER_OR_ILP32 */
68 kern_return_t
kxld_symtab_init_from_macho_64(KXLDSymtab
*symtab
,
69 struct symtab_command
*src
, u_char
*macho
, KXLDSeg
* kernel_linkedit_seg
)
70 __attribute__((nonnull(1,2), visibility("hidden")));
71 #endif /* KXLD_USER_OR_ILP64 */
73 void kxld_symtab_iterator_init(KXLDSymtabIterator
*iter
,
74 const KXLDSymtab
*symtab
, KXLDSymPredicateTest test
, boolean_t negate
)
75 __attribute__((nonnull
, visibility("hidden")));
77 void kxld_symtab_clear(KXLDSymtab
*symtab
)
78 __attribute__((nonnull
, visibility("hidden")));
80 void kxld_symtab_deinit(KXLDSymtab
*symtab
)
81 __attribute__((nonnull
, visibility("hidden")));
83 /*******************************************************************************
85 *******************************************************************************/
87 u_int
kxld_symtab_get_num_symbols(const KXLDSymtab
*symtab
)
88 __attribute__((pure
, nonnull
, visibility("hidden")));
90 KXLDSym
* kxld_symtab_get_symbol_by_index(const KXLDSymtab
*symtab
, u_int idx
)
91 __attribute__((pure
, nonnull
, visibility("hidden")));
93 KXLDSym
* kxld_symtab_get_symbol_by_name(const KXLDSymtab
*symtab
,
95 __attribute__((pure
, nonnull
, visibility("hidden")));
97 KXLDSym
* kxld_symtab_get_locally_defined_symbol_by_name(
98 const KXLDSymtab
*symtab
, const char *name
)
99 __attribute__((pure
, nonnull
, visibility("hidden")));
101 KXLDSym
* kxld_symtab_get_cxx_symbol_by_value(const KXLDSymtab
*symtab
,
103 __attribute__((pure
, nonnull
, visibility("hidden")));
105 kern_return_t
kxld_symtab_get_sym_index(const KXLDSymtab
*symtab
,
106 const KXLDSym
* sym
, u_int
*idx
)
107 __attribute__((nonnull
, visibility("hidden")));
109 u_long
kxld_symtab_get_macho_header_size(void)
110 __attribute__((pure
, visibility("hidden")));
112 u_long
kxld_symtab_get_macho_data_size(const KXLDSymtab
*symtab
,
114 __attribute__((pure
, nonnull
, visibility("hidden")));
117 kxld_symtab_export_macho(const KXLDSymtab
*symtab
, u_char
*buf
,
118 u_long
*header_offset
, u_long header_size
,
119 u_long
*data_offset
, u_long data_size
,
121 __attribute__((nonnull
, visibility("hidden")));
123 u_int
kxld_symtab_iterator_get_num_remaining(const KXLDSymtabIterator
*iter
)
124 __attribute__((pure
, nonnull
, visibility("hidden")));
126 /*******************************************************************************
128 *******************************************************************************/
130 kern_return_t
kxld_symtab_index_symbols_by_name(KXLDSymtab
*symtab
)
131 __attribute__((nonnull
, visibility("hidden")));
133 kern_return_t
kxld_symtab_index_cxx_symbols_by_value(KXLDSymtab
*symtab
)
134 __attribute__((nonnull
, visibility("hidden")));
136 kern_return_t
kxld_symtab_relocate(KXLDSymtab
*symtab
,
137 const struct kxld_array
*sectarray
)
138 __attribute__((nonnull
, visibility("hidden")));
140 kern_return_t
kxld_symtab_add_symbol(KXLDSymtab
*symtab
, char *name
,
141 kxld_addr_t link_addr
, KXLDSym
**symout
)
142 __attribute__((nonnull
, visibility("hidden")));
144 KXLDSym
* kxld_symtab_iterator_get_next(KXLDSymtabIterator
*iter
)
145 __attribute__((nonnull
, visibility("hidden")));
147 void kxld_symtab_iterator_reset(KXLDSymtabIterator
*iter
)
148 __attribute__((nonnull
, visibility("hidden")));
150 #endif /* _KXLD_SYMTAB_H_ */