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

