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