]> git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/mach-o/kld.h
xnu-517.tar.gz
[apple/xnu.git] / EXTERNAL_HEADERS / mach-o / kld.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26 #ifndef _MACHO_KLD_H_
27 #define _MACHO_KLD_H_
28
29 #include <mach-o/loader.h>
30 #include <stdarg.h>
31
32 /*
33 * These API's are in libkld. Both kmodload(8) and /mach_kernel should
34 * link with -lkld and then ld(1) will expand -lkld to libkld.dylib or
35 * libkld.a depending on if -dynamic or -static is in effect.
36 *
37 * Note: we are using the __DYNAMIC__ flag to indicate user space kernel
38 * linking and __STATIC__ as a synonym of KERNEL.
39 */
40
41 /*
42 * Note that you must supply the following function for error reporting when
43 * using any of the functions listed here.
44 */
45 extern void kld_error_vprintf(const char *format, va_list ap);
46
47 /*
48 * These two are only in libkld.dylib for use by kmodload(8) (user code compiled
49 * with the default -dynamic).
50 */
51 #ifdef __DYNAMIC__
52 __private_extern__ long kld_load_basefile(
53 const char *base_filename);
54
55 /* Note: this takes only one object file name */
56 __private_extern__ long kld_load(
57 struct mach_header **header_addr,
58 const char *object_filename,
59 const char *output_filename);
60
61 __private_extern__ long kld_load_from_memory(
62 struct mach_header **header_addr,
63 const char *object_name,
64 char *object_addr,
65 long object_size,
66 const char *output_filename);
67 #endif /* __DYNAMIC__ */
68
69 /*
70 * This two are only in libkld.a use by /mach_kernel (kernel code compiled with
71 * -static).
72 */
73 #ifdef __STATIC__
74 /* Note: this api does not write an output file */
75 __private_extern__ long kld_load_from_memory(
76 struct mach_header **header_addr,
77 const char *object_name,
78 char *object_addr,
79 long object_size);
80 #endif /* __STATIC__ */
81
82 __private_extern__ long kld_load_basefile_from_memory(
83 const char *base_filename,
84 char *base_addr,
85 long base_size);
86
87 __private_extern__ long kld_unload_all(
88 long deallocate_sets);
89
90 __private_extern__ long kld_lookup(
91 const char *symbol_name,
92 unsigned long *value);
93
94 __private_extern__ long kld_forget_symbol(
95 const char *symbol_name);
96
97 __private_extern__ void kld_address_func(
98 unsigned long (*func)(unsigned long size, unsigned long headers_size));
99
100 #define KLD_STRIP_ALL 0x00000000
101 #define KLD_STRIP_NONE 0x00000001
102
103 __private_extern__ void kld_set_link_options(
104 unsigned long link_options);
105
106 #endif /* _MACHO_KLD_H_ */