Print this page
9059 Simplify SMAP relocations with krtld
Portions contributed by: John Levon <john.levon@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/kobj.h
+++ new/usr/src/uts/common/sys/kobj.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 *
25 25 * Copyright 2017 RackTop Systems.
26 26 */
27 +/*
28 + * Copyright (c) 2017 Joyent, Inc.
29 + */
27 30
28 31 #ifndef _SYS_KOBJ_H
29 32 #define _SYS_KOBJ_H
30 33
31 34 #include <sys/modctl.h>
32 35 #include <sys/elf.h>
33 36 #include <sys/machelf.h>
34 37 #include <sys/vmem.h>
35 38 #include <sys/sdt.h>
36 39 #include <sys/bootstat.h>
37 40
38 41 #ifdef __cplusplus
39 42 extern "C" {
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
40 43 #endif
41 44
42 45 /*
43 46 * List of modules maintained by kobj.c
44 47 */
45 48 struct module_list {
46 49 struct module_list *next;
47 50 struct module *mp;
48 51 };
49 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 +
50 59 typedef unsigned short symid_t; /* symbol table index */
51 60 typedef unsigned char *reloc_dest_t;
52 61
53 62 typedef void module_mach;
54 63
55 64 struct module {
56 65 int total_allocated;
57 66
58 67 Ehdr hdr;
59 68 char *shdrs;
60 69 Shdr *symhdr, *strhdr;
61 70
62 71 char *depends_on;
63 72
64 73 size_t symsize;
65 74 char *symspace; /* symbols + strings + hashtbl, or NULL */
66 75 int flags;
67 76
68 77 size_t text_size;
69 78 size_t data_size;
70 79 char *text;
71 80 char *data;
72 81
73 82 unsigned int symtbl_section;
74 83 /* pointers into symspace, or NULL */
75 84 char *symtbl;
76 85 char *strings;
77 86
78 87 unsigned int hashsize;
79 88 symid_t *buckets;
80 89 symid_t *chains;
81 90
82 91 unsigned int nsyms;
83 92
84 93 unsigned int bss_align;
85 94 size_t bss_size;
86 95 uintptr_t bss;
87 96
88 97 char *filename;
89 98
90 99 struct module_list *head, *tail;
91 100 reloc_dest_t destination;
↓ open down ↓ |
32 lines elided |
↑ open up ↑ |
92 101 module_mach * machdata;
93 102 char *ctfdata;
94 103 size_t ctfsize;
95 104
96 105 char *fbt_tab;
97 106 size_t fbt_size;
98 107 size_t fbt_nentries;
99 108 caddr_t textwin;
100 109 caddr_t textwin_base;
101 110
111 + hotinline_desc_t *hi_calls;
112 +
102 113 sdt_probedesc_t *sdt_probes;
103 114 size_t sdt_nprobes;
104 115 char *sdt_tab;
105 116 size_t sdt_size;
106 117
107 118 char *sigdata;
108 119 size_t sigsize;
109 120 };
110 121
111 122 struct kobj_mem {
112 123 struct kobj_mem *km_next;
113 124 struct kobj_mem *km_prev;
114 125 uintptr_t km_addr;
115 126 size_t km_size;
116 127 uintptr_t km_alloc_addr;
117 128 size_t km_alloc_size;
118 129 };
119 130
120 131 struct _buf {
121 132 intptr_t _fd;
122 133 char *_ptr;
123 134 char *_base;
124 135 char *_name;
125 136 char *_dbuf;
126 137 int _size;
127 138 int _cnt;
128 139 int _off;
129 140 int _ln;
130 141 int _bsize;
131 142 int _iscmp;
132 143 int _dsize;
133 144 };
134 145
135 146
136 147 /*
137 148 * Statistical info.
138 149 */
139 150 typedef struct {
140 151 int nalloc;
141 152 int nfree;
142 153 int nalloc_calls;
143 154 int nfree_calls;
144 155 } kobj_stat_t;
145 156
146 157 #define kobj_filename(p) ((p)->_name)
147 158 #define kobj_linenum(p) ((p)->_ln)
148 159 #define kobj_newline(p) ((p)->_ln++)
149 160 #define kobj_getc(p) (--(p)->_cnt >= 0 ? ((int)*(p)->_ptr++):kobj_filbuf(p))
150 161 #define kobj_ungetc(p) (++(p)->_cnt > (p)->_size ? -1 : ((int)*(--(p)->_ptr)))
151 162 #define kobj_comphdr(p) ((struct comphdr *)(p)->_dbuf)
152 163
153 164 /* Offset into buffer */
154 165 #define B_OFFSET(file, off) (off % (file)->_bsize)
155 166
156 167 /* Start of page */
157 168 #define F_PAGE(file, off) (off - B_OFFSET(file, off))
158 169
159 170 #define F_BLKS(file, size) ((size / (file)->_bsize) * (file)->_bsize)
160 171
161 172 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
162 173
163 174 extern int kobj_load_module(struct modctl *, int);
164 175 extern void kobj_unload_module(struct modctl *);
165 176 extern uintptr_t kobj_lookup(struct module *, const char *);
166 177 extern Sym *kobj_lookup_all(struct module *, char *, int);
167 178 extern int kobj_addrcheck(void *, caddr_t);
168 179 extern int kobj_module_to_id(void *);
169 180 extern void kobj_getmodinfo(void *, struct modinfo *);
170 181 extern int kobj_get_needed(void *, short *, int);
171 182 extern uintptr_t kobj_getsymvalue(char *, int);
172 183 extern char *kobj_getsymname(uintptr_t, ulong_t *);
173 184 extern char *kobj_searchsym(struct module *, uintptr_t, ulong_t *);
174 185
175 186 extern int kobj_fstat(intptr_t, struct bootstat *);
176 187 extern intptr_t kobj_open(char *);
177 188 extern int kobj_path_exists(char *, int);
178 189 extern struct _buf *kobj_open_path(char *, int, int);
179 190 extern int kobj_read(intptr_t, char *, unsigned int, unsigned int);
↓ open down ↓ |
68 lines elided |
↑ open up ↑ |
180 191 extern void kobj_close(intptr_t);
181 192 extern void *kobj_alloc(size_t, int);
182 193 extern void *kobj_zalloc(size_t, int);
183 194 extern void kobj_free(void *, size_t);
184 195 extern struct _buf *kobj_open_file(char *);
185 196 extern void kobj_close_file(struct _buf *);
186 197 extern int kobj_read_file(struct _buf *, char *, unsigned, unsigned);
187 198 extern int kobj_get_filesize(struct _buf *, uint64_t *size);
188 199 extern uintptr_t kobj_getelfsym(char *, void *, int *);
189 200 extern void kobj_set_ctf(struct module *, caddr_t data, size_t size);
201 +extern void do_hotinlines(struct module *);
190 202
191 203 extern int kobj_filbuf(struct _buf *);
192 204 extern void kobj_sync(void);
193 205 #if defined(__i386) || defined(__sparc) || defined(__amd64)
194 206 extern void kobj_vmem_init(vmem_t **, vmem_t **);
195 207 #else
196 208 #error "ISA not supported"
197 209 #endif
198 210 extern caddr_t kobj_text_alloc(vmem_t *, size_t);
199 211 extern caddr_t kobj_texthole_alloc(caddr_t, size_t);
200 212 extern void kobj_texthole_free(caddr_t, size_t);
201 213 extern void kobj_stat_get(kobj_stat_t *);
202 214 extern void kobj_textwin_alloc(struct module *);
203 215 extern void kobj_textwin_free(struct module *);
204 216
205 217 #endif /* defined(_KERNEL) || defined(_FAKE_KERNEL) */
206 218
207 219 #ifdef __cplusplus
208 220 }
209 221 #endif
210 222
211 223 #endif /* !_SYS_KOBJ_H */
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX