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_STATE_H_
29 #define _KXLD_STATE_H_
31 #include <sys/types.h>
33 #include <libkern/kxld_types.h>
35 #include "kxld_types.h"
38 #include "kxld_array.h"
39 #include "kxld_util.h"
43 struct kxld_link_state_hdr
;
44 typedef struct kxld_state KXLDState
;
45 typedef struct kxld_link_state_hdr KXLDLinkStateHdr
;
46 typedef struct kxld_vtable_hdr KXLDVTableHdr
;
47 typedef struct kxld_sym_entry_32 KXLDSymEntry32
;
48 typedef struct kxld_sym_entry_64 KXLDSymEntry64
;
57 * The format of the link state object is as follows:
60 **************************************************
61 * Link state header *** KXLDLinkStateHdr *
62 **************************************************
63 * Section order entries *** KXLDSectionName *
64 **************************************************
65 * Vtable headers *** KXLDVTableHdr *
66 **************************************************
67 * VTables *** KXLDSymEntry[32|64] *
68 **************************************************
69 * Exported symbols *** KXLDSymEntry[32|64] *
70 **************************************************
71 * String table *** char[] *
72 **************************************************
76 struct kxld_link_state_hdr
{
80 cpu_subtype_t cpusubtype
;
89 struct kxld_vtable_hdr
{
95 struct kxld_sym_entry_32
{
101 struct kxld_sym_entry_64
{
105 } __attribute__((aligned(16)));
107 #define KXLD_SYM_OBSOLETE 0x1
109 /*******************************************************************************
110 * Constructors and destructors
111 *******************************************************************************/
113 kern_return_t
kxld_state_init_from_file(KXLDState
*state
, u_char
*file
,
114 KXLDArray
*section_order
)
115 __attribute__((nonnull(1,2), visibility("hidden")));
117 void kxld_state_clear(KXLDState
*state
)
118 __attribute__((nonnull
, visibility("hidden")));
120 void kxld_state_deinit(KXLDState
*state
)
121 __attribute__((nonnull
, visibility("hidden")));
123 /*******************************************************************************
125 *******************************************************************************/
127 u_int
kxld_state_get_num_symbols(KXLDState
*state
)
128 __attribute__((pure
, nonnull
, visibility("hidden")));
130 kern_return_t
kxld_state_get_symbols(KXLDState
*state
,
131 struct kxld_dict
*defined_symbols
,
132 struct kxld_dict
*obsolete_symbols
)
133 __attribute__((nonnull
, visibility("hidden")));
135 u_int
kxld_state_get_num_vtables(KXLDState
*state
)
136 __attribute__((pure
, nonnull
, visibility("hidden")));
138 kern_return_t
kxld_state_get_vtables(KXLDState
*state
,
139 struct kxld_dict
*patched_vtables
)
140 __attribute__((nonnull
, visibility("hidden")));
142 void kxld_state_get_cputype(const KXLDState
*state
,
143 cpu_type_t
*cputype
, cpu_subtype_t
*cpusubtype
)
144 __attribute__((nonnull
, visibility("hidden")));
146 /*******************************************************************************
148 *******************************************************************************/
150 kern_return_t
kxld_state_export_kext_to_file(struct kxld_kext
*kext
, u_char
**file
,
151 u_long
*filesize
, struct kxld_dict
*tmpdict
, KXLDArray
*tmps
)
152 __attribute__((nonnull
, visibility("hidden")));
154 #endif /* _KXLD_STATE_H_ */