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