]> git.saurik.com Git - apple/xnu.git/blame - libkern/kxld/kxld_object.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / libkern / kxld / kxld_object.h
CommitLineData
6d2010ae 1/*
316670eb 2 * Copyright (c) 2009, 2012 Apple Inc. All rights reserved.
6d2010ae
A
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
6d2010ae
A
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.
0a7de745 14 *
6d2010ae
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
6d2010ae
A
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.
0a7de745 25 *
6d2010ae
A
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28#ifndef _KXLD_OBJECT_H_
29#define _KXLD_OBJECT_H_
30
6d2010ae
A
31#include <sys/types.h>
32#if KERNEL
33 #include <libkern/kxld_types.h>
34#else
35 #include "kxld_types.h"
36#endif
37
38struct kxld_array;
39struct kxld_dict;
40struct kxld_reloc;
41struct kxld_relocator;
42struct kxld_sect;
43struct kxld_sym;
44struct kxld_symtab;
45
0a7de745 46typedef struct kxld_object KXLDObject;
6d2010ae
A
47
48/*******************************************************************************
49* Constructors and destructors
50*******************************************************************************/
51
52size_t kxld_object_sizeof(void)
0a7de745
A
53__attribute__((const, visibility("hidden")));
54
55kern_return_t kxld_object_init_from_macho(KXLDObject *object,
6d2010ae
A
56 u_char *file, u_long size, const char *name,
57 struct kxld_array *section_order,
316670eb 58 cpu_type_t cputype, cpu_subtype_t cpusubtype, KXLDFlags flags)
0a7de745 59__attribute__((nonnull(1, 2, 4), visibility("hidden")));
6d2010ae
A
60
61void kxld_object_clear(KXLDObject *object)
0a7de745 62__attribute__((nonnull, visibility("hidden")));
6d2010ae
A
63
64void kxld_object_deinit(KXLDObject *object)
0a7de745 65__attribute__((nonnull, visibility("hidden")));
6d2010ae
A
66
67/*******************************************************************************
68* Accessors
69*******************************************************************************/
70
71const u_char * kxld_object_get_file(const KXLDObject *object)
0a7de745 72__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
73
74const char * kxld_object_get_name(const KXLDObject *object)
0a7de745 75__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
76
77boolean_t kxld_object_is_32_bit(const KXLDObject *object)
0a7de745 78__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
79
80boolean_t kxld_object_is_final_image(const KXLDObject *object)
0a7de745 81__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
82
83boolean_t kxld_object_is_kernel(const KXLDObject *object)
0a7de745 84__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
85
86boolean_t kxld_object_is_linked(const KXLDObject *object)
0a7de745 87__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
88
89boolean_t kxld_object_target_supports_strict_patching(const KXLDObject *object)
0a7de745 90__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
91
92boolean_t kxld_object_target_supports_common_symbols(const KXLDObject *object)
0a7de745 93__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
94
95const struct kxld_relocator * kxld_object_get_relocator(
0a7de745
A
96 const KXLDObject * object)
97__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
98
99const struct kxld_reloc * kxld_object_get_reloc_at_symbol(
0a7de745
A
100 const KXLDObject *object, const struct kxld_sym *sym)
101__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
102
103const struct kxld_sym * kxld_object_get_symbol_of_reloc(
0a7de745
A
104 const KXLDObject *object, const struct kxld_reloc *reloc,
105 const struct kxld_sect *sect)
106__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
107
108const struct kxld_sect * kxld_object_get_section_by_index(
0a7de745
A
109 const KXLDObject *object, u_int sectnum)
110__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
111
112const struct kxld_array * kxld_object_get_extrelocs(
0a7de745
A
113 const KXLDObject *object)
114__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae
A
115
116const struct kxld_symtab * kxld_object_get_symtab(const KXLDObject *object)
0a7de745 117__attribute__((pure, nonnull, visibility("hidden")));
6d2010ae 118
0a7de745 119void kxld_object_get_vmsize(const KXLDObject *object, u_long *header_size,
6d2010ae 120 u_long *vmsize)
0a7de745 121__attribute__((nonnull, visibility("hidden")));
6d2010ae 122
316670eb 123void kxld_object_set_linked_object_size(KXLDObject *object, u_long vmsize)
0a7de745 124__attribute__((nonnull, visibility("hidden")));
316670eb 125
39037602 126void kxld_object_get_vmsize_for_seg_by_name(const KXLDObject *object,
0a7de745
A
127 const char *segname,
128 u_long *vmsize)
39037602
A
129__attribute__((nonnull, visibility("hidden")));
130
131splitKextLinkInfo * kxld_object_get_link_info(KXLDObject *object)
132__attribute__((nonnull, visibility("hidden")));
133
134void kxld_object_set_link_info(KXLDObject *object,
0a7de745 135 splitKextLinkInfo *link_info)
39037602
A
136__attribute__((nonnull, visibility("hidden")));
137
138
6d2010ae
A
139/* This will be the same size as kxld_kext_get_vmsize */
140kern_return_t kxld_object_export_linked_object(const KXLDObject *object,
0a7de745
A
141 void *linked_object
142 )
143__attribute__((nonnull, visibility("hidden")));
6d2010ae 144
39037602 145
6d2010ae
A
146/*******************************************************************************
147* Modifiers
148*******************************************************************************/
149
150kern_return_t kxld_object_index_symbols_by_name(KXLDObject *object)
0a7de745 151__attribute__((nonnull, visibility("hidden")));
6d2010ae
A
152
153kern_return_t kxld_object_index_cxx_symbols_by_value(KXLDObject *object)
0a7de745 154__attribute__((nonnull, visibility("hidden")));
6d2010ae
A
155
156kern_return_t kxld_object_relocate(KXLDObject *object, kxld_addr_t link_address)
0a7de745 157__attribute__((nonnull, visibility("hidden")));
6d2010ae 158
0a7de745 159kern_return_t kxld_object_resolve_symbol(KXLDObject *object,
6d2010ae 160 const struct kxld_sym *sym, kxld_addr_t addr)
0a7de745 161__attribute__((nonnull, visibility("hidden")));
6d2010ae
A
162
163kern_return_t kxld_object_patch_symbol(KXLDObject *object,
164 const struct kxld_sym *sym)
0a7de745 165__attribute__((nonnull, visibility("hidden")));
6d2010ae 166
0a7de745 167kern_return_t kxld_object_add_symbol(KXLDObject *object, char *name,
6d2010ae 168 kxld_addr_t link_addr, const struct kxld_sym **sym_out)
0a7de745 169__attribute__((nonnull, visibility("hidden")));
6d2010ae 170
0a7de745 171kern_return_t kxld_object_process_relocations(KXLDObject *object,
6d2010ae 172 const struct kxld_dict *patched_vtables)
0a7de745 173__attribute__((nonnull, visibility("hidden")));
6d2010ae
A
174
175#endif /* _KXLD_OBJECT_H_ */