]> git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/mach-o/kld.h
xnu-344.21.73.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
38 /*
39 * Note that you must supply the following function for error reporting when
40 * using any of the functions listed here.
41 */
42 extern void kld_error_vprintf(const char *format, va_list ap);
43
44 /*
45 * This two are only in libkld.dylib for use by kmodload(8) (user code compiled
46 * with the default -dynamic).
47 */
48 #ifdef __DYNAMIC__
49 __private_extern__ long kld_load_basefile(
50 const char *base_filename);
51
52 /* Note: this takes only one object file name */
53 __private_extern__ long kld_load(
54 struct mach_header **header_addr,
55 const char *object_filename,
56 const char *output_filename);
57 #endif /* __DYNAMIC__ */
58
59 /*
60 * This two are only in libkld.a use by /mach_kernel (kernel code compiled with
61 * -static).
62 */
63 #ifdef __STATIC__
64 /* Note: this api does not write an output file */
65 __private_extern__ long kld_load_from_memory(
66 struct mach_header **header_addr,
67 const char *object_name,
68 char *object_addr,
69 long object_size);
70 #endif /* __STATIC__ */
71
72 __private_extern__ long kld_unload_all(
73 long deallocate_sets);
74
75 __private_extern__ long kld_lookup(
76 const char *symbol_name,
77 unsigned long *value);
78
79 __private_extern__ long kld_forget_symbol(
80 const char *symbol_name);
81
82 __private_extern__ void kld_address_func(
83 unsigned long (*func)(unsigned long size, unsigned long headers_size));
84
85 #endif /* _MACHO_KLD_H_ */