7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright 2017 RackTop Systems.
26 */
27
28 #ifndef _SYS_KOBJ_H
29 #define _SYS_KOBJ_H
30
31 #include <sys/modctl.h>
32 #include <sys/elf.h>
33 #include <sys/machelf.h>
34 #include <sys/vmem.h>
35 #include <sys/sdt.h>
36 #include <sys/bootstat.h>
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /*
43 * List of modules maintained by kobj.c
44 */
45 struct module_list {
46 struct module_list *next;
47 struct module *mp;
48 };
49
50 typedef unsigned short symid_t; /* symbol table index */
51 typedef unsigned char *reloc_dest_t;
52
53 typedef void module_mach;
54
55 struct module {
56 int total_allocated;
57
58 Ehdr hdr;
59 char *shdrs;
60 Shdr *symhdr, *strhdr;
61
62 char *depends_on;
63
64 size_t symsize;
65 char *symspace; /* symbols + strings + hashtbl, or NULL */
66 int flags;
67
68 size_t text_size;
69 size_t data_size;
82 unsigned int nsyms;
83
84 unsigned int bss_align;
85 size_t bss_size;
86 uintptr_t bss;
87
88 char *filename;
89
90 struct module_list *head, *tail;
91 reloc_dest_t destination;
92 module_mach * machdata;
93 char *ctfdata;
94 size_t ctfsize;
95
96 char *fbt_tab;
97 size_t fbt_size;
98 size_t fbt_nentries;
99 caddr_t textwin;
100 caddr_t textwin_base;
101
102 sdt_probedesc_t *sdt_probes;
103 size_t sdt_nprobes;
104 char *sdt_tab;
105 size_t sdt_size;
106
107 char *sigdata;
108 size_t sigsize;
109 };
110
111 struct kobj_mem {
112 struct kobj_mem *km_next;
113 struct kobj_mem *km_prev;
114 uintptr_t km_addr;
115 size_t km_size;
116 uintptr_t km_alloc_addr;
117 size_t km_alloc_size;
118 };
119
120 struct _buf {
121 intptr_t _fd;
170 extern int kobj_get_needed(void *, short *, int);
171 extern uintptr_t kobj_getsymvalue(char *, int);
172 extern char *kobj_getsymname(uintptr_t, ulong_t *);
173 extern char *kobj_searchsym(struct module *, uintptr_t, ulong_t *);
174
175 extern int kobj_fstat(intptr_t, struct bootstat *);
176 extern intptr_t kobj_open(char *);
177 extern int kobj_path_exists(char *, int);
178 extern struct _buf *kobj_open_path(char *, int, int);
179 extern int kobj_read(intptr_t, char *, unsigned int, unsigned int);
180 extern void kobj_close(intptr_t);
181 extern void *kobj_alloc(size_t, int);
182 extern void *kobj_zalloc(size_t, int);
183 extern void kobj_free(void *, size_t);
184 extern struct _buf *kobj_open_file(char *);
185 extern void kobj_close_file(struct _buf *);
186 extern int kobj_read_file(struct _buf *, char *, unsigned, unsigned);
187 extern int kobj_get_filesize(struct _buf *, uint64_t *size);
188 extern uintptr_t kobj_getelfsym(char *, void *, int *);
189 extern void kobj_set_ctf(struct module *, caddr_t data, size_t size);
190
191 extern int kobj_filbuf(struct _buf *);
192 extern void kobj_sync(void);
193 #if defined(__i386) || defined(__sparc) || defined(__amd64)
194 extern void kobj_vmem_init(vmem_t **, vmem_t **);
195 #else
196 #error "ISA not supported"
197 #endif
198 extern caddr_t kobj_text_alloc(vmem_t *, size_t);
199 extern caddr_t kobj_texthole_alloc(caddr_t, size_t);
200 extern void kobj_texthole_free(caddr_t, size_t);
201 extern void kobj_stat_get(kobj_stat_t *);
202 extern void kobj_textwin_alloc(struct module *);
203 extern void kobj_textwin_free(struct module *);
204
205 #endif /* defined(_KERNEL) || defined(_FAKE_KERNEL) */
206
207 #ifdef __cplusplus
208 }
209 #endif
|
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright 2017 RackTop Systems.
26 */
27 /*
28 * Copyright (c) 2017 Joyent, Inc.
29 */
30
31 #ifndef _SYS_KOBJ_H
32 #define _SYS_KOBJ_H
33
34 #include <sys/modctl.h>
35 #include <sys/elf.h>
36 #include <sys/machelf.h>
37 #include <sys/vmem.h>
38 #include <sys/sdt.h>
39 #include <sys/bootstat.h>
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 /*
46 * List of modules maintained by kobj.c
47 */
48 struct module_list {
49 struct module_list *next;
50 struct module *mp;
51 };
52
53 typedef struct hotinline_desc {
54 char *hid_symname; /* symbol name */
55 uintptr_t hid_instr_offset; /* offset of call in text */
56 struct hotinline_desc *hid_next; /* next hotinline */
57 } hotinline_desc_t;
58
59 typedef unsigned short symid_t; /* symbol table index */
60 typedef unsigned char *reloc_dest_t;
61
62 typedef void module_mach;
63
64 struct module {
65 int total_allocated;
66
67 Ehdr hdr;
68 char *shdrs;
69 Shdr *symhdr, *strhdr;
70
71 char *depends_on;
72
73 size_t symsize;
74 char *symspace; /* symbols + strings + hashtbl, or NULL */
75 int flags;
76
77 size_t text_size;
78 size_t data_size;
91 unsigned int nsyms;
92
93 unsigned int bss_align;
94 size_t bss_size;
95 uintptr_t bss;
96
97 char *filename;
98
99 struct module_list *head, *tail;
100 reloc_dest_t destination;
101 module_mach * machdata;
102 char *ctfdata;
103 size_t ctfsize;
104
105 char *fbt_tab;
106 size_t fbt_size;
107 size_t fbt_nentries;
108 caddr_t textwin;
109 caddr_t textwin_base;
110
111 hotinline_desc_t *hi_calls;
112
113 sdt_probedesc_t *sdt_probes;
114 size_t sdt_nprobes;
115 char *sdt_tab;
116 size_t sdt_size;
117
118 char *sigdata;
119 size_t sigsize;
120 };
121
122 struct kobj_mem {
123 struct kobj_mem *km_next;
124 struct kobj_mem *km_prev;
125 uintptr_t km_addr;
126 size_t km_size;
127 uintptr_t km_alloc_addr;
128 size_t km_alloc_size;
129 };
130
131 struct _buf {
132 intptr_t _fd;
181 extern int kobj_get_needed(void *, short *, int);
182 extern uintptr_t kobj_getsymvalue(char *, int);
183 extern char *kobj_getsymname(uintptr_t, ulong_t *);
184 extern char *kobj_searchsym(struct module *, uintptr_t, ulong_t *);
185
186 extern int kobj_fstat(intptr_t, struct bootstat *);
187 extern intptr_t kobj_open(char *);
188 extern int kobj_path_exists(char *, int);
189 extern struct _buf *kobj_open_path(char *, int, int);
190 extern int kobj_read(intptr_t, char *, unsigned int, unsigned int);
191 extern void kobj_close(intptr_t);
192 extern void *kobj_alloc(size_t, int);
193 extern void *kobj_zalloc(size_t, int);
194 extern void kobj_free(void *, size_t);
195 extern struct _buf *kobj_open_file(char *);
196 extern void kobj_close_file(struct _buf *);
197 extern int kobj_read_file(struct _buf *, char *, unsigned, unsigned);
198 extern int kobj_get_filesize(struct _buf *, uint64_t *size);
199 extern uintptr_t kobj_getelfsym(char *, void *, int *);
200 extern void kobj_set_ctf(struct module *, caddr_t data, size_t size);
201 extern void do_hotinlines(struct module *);
202
203 extern int kobj_filbuf(struct _buf *);
204 extern void kobj_sync(void);
205 #if defined(__i386) || defined(__sparc) || defined(__amd64)
206 extern void kobj_vmem_init(vmem_t **, vmem_t **);
207 #else
208 #error "ISA not supported"
209 #endif
210 extern caddr_t kobj_text_alloc(vmem_t *, size_t);
211 extern caddr_t kobj_texthole_alloc(caddr_t, size_t);
212 extern void kobj_texthole_free(caddr_t, size_t);
213 extern void kobj_stat_get(kobj_stat_t *);
214 extern void kobj_textwin_alloc(struct module *);
215 extern void kobj_textwin_free(struct module *);
216
217 #endif /* defined(_KERNEL) || defined(_FAKE_KERNEL) */
218
219 #ifdef __cplusplus
220 }
221 #endif
|