FreeBSD/Linux Kernel Cross Reference
sys/sys/ksyms.h
1 /* $NetBSD: ksyms.h,v 1.17.4.1 2009/03/31 23:23:15 snj Exp $ */
2
3 /*
4 * Copyright (c) 2001, 2003 Anders Magnusson (ragge@ludd.luth.se).
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #ifndef _SYS_KSYMS_H_
31 #define _SYS_KSYMS_H_
32
33 #ifdef _KSYMS_PRIVATE
34 #define ELFSIZE ARCH_ELFSIZE
35 #include <sys/exec_elf.h>
36 #include <sys/queue.h>
37
38 struct ksyms_symtab {
39 TAILQ_ENTRY(ksyms_symtab) sd_queue; /* All active tables */
40 const char *sd_name; /* Name of this table */
41 Elf_Sym *sd_symstart; /* Address of symbol table */
42 Elf_Sym *sd_minsym; /* symbol with minimum value */
43 Elf_Sym *sd_maxsym; /* symbol with maximum value */
44 char *sd_strstart; /* Address of corresponding string table */
45 int sd_usroffset; /* Real address for userspace */
46 int sd_symsize; /* Size in bytes of symbol table */
47 int sd_strsize; /* Size of string table */
48 bool sd_gone; /* dead but around for open() */
49 bool sd_malloc; /* XXX REMOVE WHEN LKMS GO */
50 };
51
52 /*
53 * Static allocated ELF header.
54 * Basic info is filled in at attach, sizes at open.
55 */
56 #define SYMTAB 1
57 #define STRTAB 2
58 #define SHSTRTAB 3
59 #define NSECHDR 4
60
61 #define NPRGHDR 2
62 #define SHSTRSIZ 32
63
64 struct ksyms_hdr {
65 Elf_Ehdr kh_ehdr;
66 Elf_Phdr kh_phdr[NPRGHDR];
67 Elf_Shdr kh_shdr[NSECHDR];
68 char kh_strtab[SHSTRSIZ];
69 };
70 #endif /* _KSYMS_PRIVATE */
71
72 /*
73 * Do a lookup of a symbol using the in-kernel lookup algorithm.
74 */
75 struct ksyms_gsymbol {
76 const char *kg_name;
77 union {
78 void *ku_sym; /* Normally Elf_Sym */
79 unsigned long *ku_value;
80 } _un;
81 #define kg_sym _un.ku_sym
82 #define kg_value _un.ku_value
83 };
84
85 #define KIOCGSYMBOL _IOW('l', 1, struct ksyms_gsymbol)
86 #define KIOCGVALUE _IOW('l', 2, struct ksyms_gsymbol)
87 #define KIOCGSIZE _IOR('l', 3, int)
88
89
90 #ifdef _KERNEL
91 /*
92 * Definitions used in ksyms_getname() and ksyms_getval().
93 */
94 #define KSYMS_CLOSEST 0001 /* Nearest lower match */
95 #define KSYMS_EXACT 0002 /* Only exact match allowed */
96 #define KSYMS_EXTERN 0000 /* Only external symbols (pseudo) */
97 #define KSYMS_PROC 0100 /* Procedures only */
98 #define KSYMS_ANY 0200 /* Also local symbols (DDB use only) */
99
100 /*
101 * Prototypes
102 */
103 int ksyms_getname(const char **, const char **, vaddr_t, int);
104 int ksyms_getval(const char *, const char *, unsigned long *, int);
105 int ksyms_getval_unlocked(const char *, const char *, unsigned long *, int);
106 int ksyms_addsymtab(const char *, void *, vsize_t, char *, vsize_t);
107 int ksyms_delsymtab(const char *);
108 void ksyms_init(int, void *, void *);
109 void ksyms_init_explicit(void *, void *, size_t, void *, size_t);
110 void ksyms_init_finalize(void);
111 int ksyms_sift(char *, char *, int);
112 void ksyms_modload(const char *, void *, vsize_t, char *, vsize_t);
113 void ksyms_modunload(const char *);
114
115 #endif /* _KERNEL */
116 #endif /* _SYS_KSYMS_H_ */
Cache object: 63195095957875687533887dc117debd
|