xref: /illumos-gate/usr/src/cmd/sgs/elfdump/common/struct_layout_i386.c (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
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 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /*
27  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
28  * Copyright 2018 Joyent, Inc.
29  * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
30  */
31 
32 #include <struct_layout.h>
33 
34 
35 static const sl_auxv_layout_t auxv_layout = {
36 	{ 0,	8,	0,	0 },		/* sizeof (auxv_t) */
37 	{ 0,	4,	0,	1 },		/* a_type */
38 	{ 4,	4,	0,	1 },		/* a_un.a_val */
39 	{ 4,	4,	0,	0 },		/* a_un.a_ptr */
40 	{ 4,	4,	0,	0 },		/* a_un.a_fcn */
41 };
42 
43 
44 static const sl_prgregset_layout_t prgregset_layout = {
45 	{ 0,	76,	0,	0 },		/* sizeof (prgregset_t) */
46 	{ 0,	4,	19,	0 },		/* elt0 */
47 };
48 
49 
50 static const sl_lwpstatus_layout_t lwpstatus_layout = {
51 	{ 0,	800,	0,	0 },		/* sizeof (lwpstatus_t) */
52 	{ 0,	4,	0,	0 },		/* pr_flags */
53 	{ 4,	4,	0,	0 },		/* pr_lwpid */
54 	{ 8,	2,	0,	0 },		/* pr_why */
55 	{ 10,	2,	0,	0 },		/* pr_what */
56 	{ 12,	2,	0,	0 },		/* pr_cursig */
57 	{ 16,	128,	0,	0 },		/* pr_info */
58 	{ 144,	16,	0,	0 },		/* pr_lwppend */
59 	{ 160,	16,	0,	0 },		/* pr_lwphold */
60 	{ 176,	32,	0,	0 },		/* pr_action */
61 	{ 208,	12,	0,	0 },		/* pr_altstack */
62 	{ 220,	4,	0,	0 },		/* pr_oldcontext */
63 	{ 224,	2,	0,	0 },		/* pr_syscall */
64 	{ 226,	2,	0,	0 },		/* pr_nsysarg */
65 	{ 228,	4,	0,	0 },		/* pr_errno */
66 	{ 232,	4,	8,	0 },		/* pr_sysarg[] */
67 	{ 264,	4,	0,	0 },		/* pr_rval1 */
68 	{ 268,	4,	0,	0 },		/* pr_rval2 */
69 	{ 272,	1,	8,	0 },		/* pr_clname[] */
70 	{ 280,	8,	0,	0 },		/* pr_tstamp */
71 	{ 288,	8,	0,	0 },		/* pr_utime */
72 	{ 296,	8,	0,	0 },		/* pr_stime */
73 	{ 332,	4,	0,	0 },		/* pr_errpriv */
74 	{ 336,	4,	0,	0 },		/* pr_ustack */
75 	{ 340,	4,	0,	0 },		/* pr_instr */
76 	{ 344,	76,	0,	0 },		/* pr_reg */
77 	{ 420,	380,	0,	0 },		/* pr_fpreg */
78 };
79 
80 
81 static const sl_pstatus_layout_t pstatus_layout = {
82 	{ 0,	1136,	0,	0 },		/* sizeof (pstatus_t) */
83 	{ 0,	4,	0,	1 },		/* pr_flags */
84 	{ 4,	4,	0,	1 },		/* pr_nlwp */
85 	{ 8,	4,	0,	0 },		/* pr_pid */
86 	{ 12,	4,	0,	0 },		/* pr_ppid */
87 	{ 16,	4,	0,	0 },		/* pr_pgid */
88 	{ 20,	4,	0,	0 },		/* pr_sid */
89 	{ 24,	4,	0,	1 },		/* pr_aslwpid */
90 	{ 28,	4,	0,	1 },		/* pr_agentid */
91 	{ 32,	16,	0,	0 },		/* pr_sigpend */
92 	{ 48,	4,	0,	0 },		/* pr_brkbase */
93 	{ 52,	4,	0,	0 },		/* pr_brksize */
94 	{ 56,	4,	0,	0 },		/* pr_stkbase */
95 	{ 60,	4,	0,	0 },		/* pr_stksize */
96 	{ 64,	8,	0,	0 },		/* pr_utime */
97 	{ 72,	8,	0,	0 },		/* pr_stime */
98 	{ 80,	8,	0,	0 },		/* pr_cutime */
99 	{ 88,	8,	0,	0 },		/* pr_cstime */
100 	{ 96,	16,	0,	0 },		/* pr_sigtrace */
101 	{ 112,	16,	0,	0 },		/* pr_flttrace */
102 	{ 128,	64,	0,	0 },		/* pr_sysentry */
103 	{ 192,	64,	0,	0 },		/* pr_sysexit */
104 	{ 256,	1,	0,	0 },		/* pr_dmodel */
105 	{ 260,	4,	0,	1 },		/* pr_taskid */
106 	{ 264,	4,	0,	1 },		/* pr_projid */
107 	{ 268,	4,	0,	1 },		/* pr_nzomb */
108 	{ 272,	4,	0,	1 },		/* pr_zoneid */
109 	{ 336,	800,	0,	0 },		/* pr_lwp */
110 };
111 
112 
113 static const sl_prstatus_layout_t prstatus_layout = {
114 	{ 0,	432,	0,	0 },		/* sizeof (prstatus_t) */
115 	{ 0,	4,	0,	1 },		/* pr_flags */
116 	{ 4,	2,	0,	1 },		/* pr_why */
117 	{ 6,	2,	0,	1 },		/* pr_what */
118 	{ 8,	128,	0,	0 },		/* pr_info */
119 	{ 136,	2,	0,	1 },		/* pr_cursig */
120 	{ 138,	2,	0,	0 },		/* pr_nlwp */
121 	{ 140,	16,	0,	0 },		/* pr_sigpend */
122 	{ 156,	16,	0,	0 },		/* pr_sighold */
123 	{ 172,	12,	0,	0 },		/* pr_altstack */
124 	{ 184,	32,	0,	0 },		/* pr_action */
125 	{ 216,	4,	0,	0 },		/* pr_pid */
126 	{ 220,	4,	0,	0 },		/* pr_ppid */
127 	{ 224,	4,	0,	0 },		/* pr_pgrp */
128 	{ 228,	4,	0,	0 },		/* pr_sid */
129 	{ 232,	8,	0,	0 },		/* pr_utime */
130 	{ 240,	8,	0,	0 },		/* pr_stime */
131 	{ 248,	8,	0,	0 },		/* pr_cutime */
132 	{ 256,	8,	0,	0 },		/* pr_cstime */
133 	{ 264,	1,	8,	0 },		/* pr_clname[] */
134 	{ 272,	2,	0,	1 },		/* pr_syscall */
135 	{ 274,	2,	0,	1 },		/* pr_nsysarg */
136 	{ 276,	4,	8,	1 },		/* pr_sysarg[] */
137 	{ 308,	4,	0,	0 },		/* pr_who */
138 	{ 312,	16,	0,	0 },		/* pr_lwppend */
139 	{ 328,	4,	0,	0 },		/* pr_oldcontext */
140 	{ 332,	4,	0,	0 },		/* pr_brkbase */
141 	{ 336,	4,	0,	0 },		/* pr_brksize */
142 	{ 340,	4,	0,	0 },		/* pr_stkbase */
143 	{ 344,	4,	0,	0 },		/* pr_stksize */
144 	{ 348,	2,	0,	1 },		/* pr_processor */
145 	{ 350,	2,	0,	1 },		/* pr_bind */
146 	{ 352,	4,	0,	1 },		/* pr_instr */
147 	{ 356,	76,	0,	0 },		/* pr_reg */
148 };
149 
150 
151 static const sl_psinfo_layout_t psinfo_layout = {
152 	{ 0,	336,	0,	0 },		/* sizeof (psinfo_t) */
153 	{ 0,	4,	0,	1 },		/* pr_flag */
154 	{ 4,	4,	0,	1 },		/* pr_nlwp */
155 	{ 8,	4,	0,	0 },		/* pr_pid */
156 	{ 12,	4,	0,	0 },		/* pr_ppid */
157 	{ 16,	4,	0,	0 },		/* pr_pgid */
158 	{ 20,	4,	0,	0 },		/* pr_sid */
159 	{ 24,	4,	0,	0 },		/* pr_uid */
160 	{ 28,	4,	0,	0 },		/* pr_euid */
161 	{ 32,	4,	0,	0 },		/* pr_gid */
162 	{ 36,	4,	0,	0 },		/* pr_egid */
163 	{ 40,	4,	0,	0 },		/* pr_addr */
164 	{ 44,	4,	0,	0 },		/* pr_size */
165 	{ 48,	4,	0,	0 },		/* pr_rssize */
166 	{ 56,	4,	0,	0 },		/* pr_ttydev */
167 	{ 60,	2,	0,	0 },		/* pr_pctcpu */
168 	{ 62,	2,	0,	0 },		/* pr_pctmem */
169 	{ 64,	8,	0,	0 },		/* pr_start */
170 	{ 72,	8,	0,	0 },		/* pr_time */
171 	{ 80,	8,	0,	0 },		/* pr_ctime */
172 	{ 88,	1,	16,	0 },		/* pr_fname[] */
173 	{ 104,	1,	80,	0 },		/* pr_psargs[] */
174 	{ 184,	4,	0,	1 },		/* pr_wstat */
175 	{ 188,	4,	0,	1 },		/* pr_argc */
176 	{ 192,	4,	0,	0 },		/* pr_argv */
177 	{ 196,	4,	0,	0 },		/* pr_envp */
178 	{ 200,	1,	0,	0 },		/* pr_dmodel */
179 	{ 204,	4,	0,	0 },		/* pr_taskid */
180 	{ 208,	4,	0,	0 },		/* pr_projid */
181 	{ 212,	4,	0,	1 },		/* pr_nzomb */
182 	{ 216,	4,	0,	0 },		/* pr_poolid */
183 	{ 220,	4,	0,	0 },		/* pr_zoneid */
184 	{ 224,	4,	0,	0 },		/* pr_contract */
185 	{ 232,	104,	0,	0 },		/* pr_lwp */
186 };
187 
188 
189 static const sl_prpsinfo_layout_t prpsinfo_layout = {
190 	{ 0,	260,	0,	0 },		/* sizeof (prpsinfo_t) */
191 	{ 0,	1,	0,	0 },		/* pr_state */
192 	{ 1,	1,	0,	0 },		/* pr_sname */
193 	{ 2,	1,	0,	0 },		/* pr_zomb */
194 	{ 3,	1,	0,	0 },		/* pr_nice */
195 	{ 4,	4,	0,	0 },		/* pr_flag */
196 	{ 8,	4,	0,	0 },		/* pr_uid */
197 	{ 12,	4,	0,	0 },		/* pr_gid */
198 	{ 16,	4,	0,	0 },		/* pr_pid */
199 	{ 20,	4,	0,	0 },		/* pr_ppid */
200 	{ 24,	4,	0,	0 },		/* pr_pgrp */
201 	{ 28,	4,	0,	0 },		/* pr_sid */
202 	{ 32,	4,	0,	0 },		/* pr_addr */
203 	{ 36,	4,	0,	0 },		/* pr_size */
204 	{ 40,	4,	0,	0 },		/* pr_rssize */
205 	{ 44,	4,	0,	0 },		/* pr_wchan */
206 	{ 48,	8,	0,	0 },		/* pr_start */
207 	{ 56,	8,	0,	0 },		/* pr_time */
208 	{ 64,	4,	0,	1 },		/* pr_pri */
209 	{ 68,	1,	0,	0 },		/* pr_oldpri */
210 	{ 69,	1,	0,	0 },		/* pr_cpu */
211 	{ 70,	2,	0,	0 },		/* pr_ottydev */
212 	{ 72,	4,	0,	0 },		/* pr_lttydev */
213 	{ 76,	1,	8,	0 },		/* pr_clname[] */
214 	{ 84,	1,	16,	0 },		/* pr_fname[] */
215 	{ 100,	1,	80,	0 },		/* pr_psargs[] */
216 	{ 180,	2,	0,	1 },		/* pr_syscall */
217 	{ 184,	8,	0,	0 },		/* pr_ctime */
218 	{ 192,	4,	0,	0 },		/* pr_bysize */
219 	{ 196,	4,	0,	0 },		/* pr_byrssize */
220 	{ 200,	4,	0,	1 },		/* pr_argc */
221 	{ 204,	4,	0,	0 },		/* pr_argv */
222 	{ 208,	4,	0,	0 },		/* pr_envp */
223 	{ 212,	4,	0,	1 },		/* pr_wstat */
224 	{ 216,	2,	0,	0 },		/* pr_pctcpu */
225 	{ 218,	2,	0,	0 },		/* pr_pctmem */
226 	{ 220,	4,	0,	0 },		/* pr_euid */
227 	{ 224,	4,	0,	0 },		/* pr_egid */
228 	{ 228,	4,	0,	0 },		/* pr_aslwpid */
229 	{ 232,	1,	0,	0 },		/* pr_dmodel */
230 };
231 
232 
233 static const sl_lwpsinfo_layout_t lwpsinfo_layout = {
234 	{ 0,	104,	0,	0 },		/* sizeof (lwpsinfo_t) */
235 	{ 0,	4,	0,	1 },		/* pr_flag */
236 	{ 4,	4,	0,	0 },		/* pr_lwpid */
237 	{ 8,	4,	0,	0 },		/* pr_addr */
238 	{ 12,	4,	0,	0 },		/* pr_wchan */
239 	{ 16,	1,	0,	0 },		/* pr_stype */
240 	{ 17,	1,	0,	0 },		/* pr_state */
241 	{ 18,	1,	0,	0 },		/* pr_sname */
242 	{ 19,	1,	0,	0 },		/* pr_nice */
243 	{ 20,	2,	0,	0 },		/* pr_syscall */
244 	{ 22,	1,	0,	0 },		/* pr_oldpri */
245 	{ 23,	1,	0,	0 },		/* pr_cpu */
246 	{ 24,	4,	0,	1 },		/* pr_pri */
247 	{ 28,	2,	0,	0 },		/* pr_pctcpu */
248 	{ 32,	8,	0,	0 },		/* pr_start */
249 	{ 40,	8,	0,	0 },		/* pr_time */
250 	{ 48,	1,	8,	0 },		/* pr_clname[] */
251 	{ 56,	1,	16,	0 },		/* pr_name[] */
252 	{ 72,	4,	0,	1 },		/* pr_onpro */
253 	{ 76,	4,	0,	1 },		/* pr_bindpro */
254 	{ 80,	4,	0,	1 },		/* pr_bindpset */
255 	{ 84,	4,	0,	1 },		/* pr_lgrp */
256 };
257 
258 
259 static const sl_prcred_layout_t prcred_layout = {
260 	{ 0,	32,	0,	0 },		/* sizeof (prcred_t) */
261 	{ 0,	4,	0,	0 },		/* pr_euid */
262 	{ 4,	4,	0,	0 },		/* pr_ruid */
263 	{ 8,	4,	0,	0 },		/* pr_suid */
264 	{ 12,	4,	0,	0 },		/* pr_egid */
265 	{ 16,	4,	0,	0 },		/* pr_rgid */
266 	{ 20,	4,	0,	0 },		/* pr_sgid */
267 	{ 24,	4,	0,	1 },		/* pr_ngroups */
268 	{ 28,	4,	1,	0 },		/* pr_groups[] */
269 };
270 
271 
272 static const sl_prpriv_layout_t prpriv_layout = {
273 	{ 0,	16,	0,	0 },		/* sizeof (prpriv_t) */
274 	{ 0,	4,	0,	0 },		/* pr_nsets */
275 	{ 4,	4,	0,	0 },		/* pr_setsize */
276 	{ 8,	4,	0,	0 },		/* pr_infosize */
277 	{ 12,	4,	1,	0 },		/* pr_sets[] */
278 };
279 
280 
281 static const sl_priv_impl_info_layout_t priv_impl_info_layout = {
282 	{ 0,	28,	0,	0 },		/* sizeof (priv_impl_info_t) */
283 	{ 0,	4,	0,	0 },		/* priv_headersize */
284 	{ 4,	4,	0,	0 },		/* priv_flags */
285 	{ 8,	4,	0,	0 },		/* priv_nsets */
286 	{ 12,	4,	0,	0 },		/* priv_setsize */
287 	{ 16,	4,	0,	0 },		/* priv_max */
288 	{ 20,	4,	0,	0 },		/* priv_infosize */
289 	{ 24,	4,	0,	0 },		/* priv_globalinfosize */
290 };
291 
292 
293 static const sl_fltset_layout_t fltset_layout = {
294 	{ 0,	16,	0,	0 },		/* sizeof (fltset_t) */
295 	{ 0,	4,	4,	0 },		/* word[] */
296 };
297 
298 
299 static const sl_siginfo_layout_t siginfo_layout = {
300 	{ 0,	128,	0,	0 },		/* sizeof (siginfo_t) */
301 	{ 0,	4,	0,	0 },		/* si_signo */
302 	{ 8,	4,	0,	0 },		/* si_errno */
303 	{ 4,	4,	0,	1 },		/* si_code */
304 	{ 20,	4,	0,	0 },		/* si_value.sival_int */
305 	{ 20,	4,	0,	0 },		/* si_value.sival_ptr */
306 	{ 12,	4,	0,	0 },		/* si_pid */
307 	{ 16,	4,	0,	0 },		/* si_uid */
308 	{ 28,	4,	0,	0 },		/* si_ctid */
309 	{ 32,	4,	0,	0 },		/* si_zoneid */
310 	{ 12,	4,	0,	0 },		/* si_entity */
311 	{ 12,	4,	0,	0 },		/* si_addr */
312 	{ 20,	4,	0,	0 },		/* si_status */
313 	{ 16,	4,	0,	0 },		/* si_band */
314 };
315 
316 
317 static const sl_sigset_layout_t sigset_layout = {
318 	{ 0,	16,	0,	0 },		/* sizeof (sigset_t) */
319 	{ 0,	4,	4,	0 },		/* __sigbits[] */
320 };
321 
322 
323 static const sl_sigaction_layout_t sigaction_layout = {
324 	{ 0,	32,	0,	0 },		/* sizeof (struct sigaction) */
325 	{ 0,	4,	0,	0 },		/* sa_flags */
326 	{ 4,	4,	0,	0 },		/* sa_handler */
327 	{ 4,	4,	0,	0 },		/* sa_sigaction */
328 	{ 8,	16,	0,	0 },		/* sa_mask */
329 };
330 
331 
332 static const sl_stack_layout_t stack_layout = {
333 	{ 0,	12,	0,	0 },		/* sizeof (stack_t) */
334 	{ 0,	4,	0,	0 },		/* ss_sp */
335 	{ 4,	4,	0,	0 },		/* ss_size */
336 	{ 8,	4,	0,	0 },		/* ss_flags */
337 };
338 
339 
340 static const sl_sysset_layout_t sysset_layout = {
341 	{ 0,	64,	0,	0 },		/* sizeof (sysset_t) */
342 	{ 0,	4,	16,	0 },		/* word[] */
343 };
344 
345 
346 static const sl_timestruc_layout_t timestruc_layout = {
347 	{ 0,	8,	0,	0 },		/* sizeof (timestruc_t) */
348 	{ 0,	4,	0,	0 },		/* tv_sec */
349 	{ 4,	4,	0,	0 },		/* tv_nsec */
350 };
351 
352 
353 static const sl_utsname_layout_t utsname_layout = {
354 	{ 0,	1285,	0,	0 },		/* sizeof (struct utsname) */
355 	{ 0,	1,	257,	0 },		/* sysname[] */
356 	{ 257,	1,	257,	0 },		/* nodename[] */
357 	{ 514,	1,	257,	0 },		/* release[] */
358 	{ 771,	1,	257,	0 },		/* version[] */
359 	{ 1028,	1,	257,	0 },		/* machine[] */
360 };
361 
362 
363 static const sl_prfdinfo_layout_t prfdinfo_layout = {
364 	{ 0,	1088,	0,	0 },		/* sizeof (prfdinfo_core_t) */
365 	{ 0,	4,	0,	0 },		/* pr_fd */
366 	{ 4,	4,	0,	0 },		/* pr_mode */
367 	{ 8,	4,	0,	0 },		/* pr_uid */
368 	{ 12,	4,	0,	0 },		/* pr_gid */
369 	{ 16,	4,	0,	0 },		/* pr_major */
370 	{ 20,	4,	0,	0 },		/* pr_minor */
371 	{ 24,	4,	0,	0 },		/* pr_rmajor */
372 	{ 28,	4,	0,	0 },		/* pr_rminor */
373 	{ 32,	8,	0,	0 },		/* pr_ino */
374 	{ 40,	8,	0,	0 },		/* pr_offset */
375 	{ 48,	8,	0,	0 },		/* pr_size */
376 	{ 56,	4,	0,	0 },		/* pr_fileflags */
377 	{ 60,	4,	0,	0 },		/* pr_fdflags */
378 	{ 64,	1,	1024,	0 },		/* pr_path[] */
379 };
380 
381 
382 static const sl_prsecflags_layout_t prsecflags_layout = {
383 	{ 0,	40,	0,	0 },		/* sizeof (prsecflags_t) */
384 	{ 0,	4,	0,	0 },		/* pr_version */
385 	{ 8,	8,	0,	0 },		/* pr_effective */
386 	{ 16,	8,	0,	0 },		/* pr_inherit */
387 	{ 24,	8,	0,	0 },		/* pr_lower */
388 	{ 32,	8,	0,	0 },		/* pr_upper */
389 };
390 
391 
392 static const sl_prlwpname_layout_t prlwpname_layout = {
393 	{ 0,	40,	0,	0 },		/* sizeof (prlwpname_t) */
394 	{ 0,	8,	0,	0 },		/* pr_lwpid */
395 	{ 8,	1,	32,	0 },		/* pr_lwpname[] */
396 };
397 
398 
399 static const sl_prupanic_layout_t prupanic_layout = {
400 	{ 0,	1032,	0,	0 },		/* sizeof (prupanic_t) */
401 	{ 0,	4,	0,	0 },		/* pru_version */
402 	{ 4,	4,	0,	0 },		/* pru_flags */
403 	{ 8,	1,	1024,	0 },		/* pru_data[] */
404 };
405 
406 
407 
408 
409 static const sl_arch_layout_t layout_i386 = {
410 	&auxv_layout,
411 	&fltset_layout,
412 	&lwpsinfo_layout,
413 	&lwpstatus_layout,
414 	&prcred_layout,
415 	&priv_impl_info_layout,
416 	&prpriv_layout,
417 	&psinfo_layout,
418 	&pstatus_layout,
419 	&prgregset_layout,
420 	&prpsinfo_layout,
421 	&prstatus_layout,
422 	&sigaction_layout,
423 	&siginfo_layout,
424 	&sigset_layout,
425 	&stack_layout,
426 	&sysset_layout,
427 	&timestruc_layout,
428 	&utsname_layout,
429 	&prfdinfo_layout,
430 	&prsecflags_layout,
431 	&prlwpname_layout,
432 	&prupanic_layout,
433 };
434 
435 
436 const sl_arch_layout_t *
437 struct_layout_i386(void)
438 {
439 	return (&layout_i386);
440 }
441