xref: /illumos-gate/usr/src/cmd/sgs/elfdump/common/gen_struct_layout.c (revision dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 
29 #include <stdlib.h>
30 #include <stddef.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <fcntl.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <unistd.h>
37 #include <sys/sysmacros.h>
38 #include <sys/corectl.h>
39 #include <procfs.h>
40 #include <sys/auxv.h>
41 #include <sys/old_procfs.h>
42 #include <sys/utsname.h>
43 
44 
45 
46 /*
47  * This standalone program is used to generate the contents
48  * of the struct_layout_XXX.c files that contain per-archtecture
49  * structure layout information.
50  *
51  * Although not part of elfdump, it is built by the makefile
52  * along with it.
53  * To use it:
54  *
55  *	1) Run it, capturing the output in a file.
56  *	2) If this is a replacement for an existing file,
57  *		diff the new and old copies to ensure only
58  *		the changes you expected are present.
59  *	3) Put the new file in the common directory under the name
60  *		struct_layout_XXX.c, where XXX is the name of
61  *		the architecture (i386, amd64, sparc, sparcv9, etc).
62  *	2) Add any necessary header and copyright comments.
63  *	3) If this is a new architecture:
64  *		- Add an extern statement for struct_layout_XXX()
65  *			to struct_layout.h
66  *		- Add a case for it to the function sl_struct_layout()
67  *			in struct_layout.c.
68  */
69 
70 
71 /*
72  * Which machine is this build for?
73  */
74 #if defined(__i386)
75 
76 #define	MACH	"i386"
77 
78 #elif defined(__amd64)
79 
80 #define	MACH	"amd64"
81 
82 #elif defined(__sparcv9)
83 
84 #define	MACH	"sparcv9"
85 
86 #elif defined(__sparc)
87 
88 #define	MACH	"sparc"
89 
90 #else
91 
92 #error "unrecognized build host type"
93 
94 #endif
95 
96 
97 /*
98  * START and END bracket a struct layout definition. They issue
99  * the typedef boilerplate, and the standard first element (sizeof)
100  * which captures the overall size of the structure.
101  *
102  * SCALAR_FIELD is for scalar struct fields
103  *
104  * ARRAY_FIELD is for  array struct fields
105  *
106  * ARRAY is for plain (non-struct) array types
107  */
108 #define	START(_name, _type) \
109 	(void) printf("\n\nstatic const sl_" #_name \
110 	    "_layout_t " #_name "_layout = {\n"); \
111 	(void) printf("\t{ 0,\t%d,\t0,\t0 },\t\t/* sizeof (%s) */\n", \
112 	    sizeof (_type), #_type)
113 #define	SCALAR_FIELD(_type, _field, _sign) \
114 	(void) printf("\t{ %d,\t%d,\t0,\t%d },\t\t/* " #_field " */\n", \
115 	    offsetof(_type, _field), sizeof (((_type *)0)->_field), _sign)
116 #define	ARRAY_FIELD(_type, _field, _sign) \
117 	(void) printf("\t{ %d,\t%d,\t%d,\t%d },\t\t/* " #_field "[] */\n", \
118 	    offsetof(_type, _field), sizeof (((_type *)0)->_field[0]), \
119 	    sizeof (((_type *)0)->_field) / sizeof (((_type *)0)->_field[0]), \
120 	    _sign)
121 #define	ARRAY(_type, _sign) \
122 	(void) printf("\t{ 0,\t%d,\t%d,\t%d },\t\t/* elt0 */\n", \
123 	    sizeof (*((_type *)0)[0]), \
124 	    sizeof (_type) / sizeof (*((_type *)0)[0]), _sign)
125 #define	END (void) printf("};\n")
126 
127 
128 /* auxv_t, <sys/auxv.h> */
129 static void
130 gen_auxv(void)
131 {
132 	START(auxv, auxv_t);
133 
134 	SCALAR_FIELD(auxv_t,	a_type,	1);
135 	SCALAR_FIELD(auxv_t,	a_un.a_val,	1);
136 	SCALAR_FIELD(auxv_t,	a_un.a_ptr,	0);
137 	SCALAR_FIELD(auxv_t,	a_un.a_fcn,	0);
138 
139 	END;
140 }
141 
142 
143 /* prgregset_t, <sys/prgregset.h> */
144 static void
145 gen_prgregset(void)
146 {
147 	START(prgregset, prgregset_t);
148 
149 	ARRAY(prgregset_t,	0);
150 
151 	END;
152 }
153 
154 
155 /* lwpstatus_t, <sys/procfs.h> */
156 static void
157 gen_lwpstatus(void)
158 {
159 	START(lwpstatus, lwpstatus_t);
160 
161 	SCALAR_FIELD(lwpstatus_t,	pr_flags,	0);
162 	SCALAR_FIELD(lwpstatus_t,	pr_lwpid,	0);
163 	SCALAR_FIELD(lwpstatus_t,	pr_why,		0);
164 	SCALAR_FIELD(lwpstatus_t,	pr_what,	0);
165 	SCALAR_FIELD(lwpstatus_t,	pr_cursig,	0);
166 	SCALAR_FIELD(lwpstatus_t,	pr_info,	0);
167 	SCALAR_FIELD(lwpstatus_t,	pr_lwppend,	0);
168 	SCALAR_FIELD(lwpstatus_t,	pr_lwphold,	0);
169 	SCALAR_FIELD(lwpstatus_t,	pr_action,	0);
170 	SCALAR_FIELD(lwpstatus_t,	pr_altstack,	0);
171 	SCALAR_FIELD(lwpstatus_t,	pr_oldcontext,	0);
172 	SCALAR_FIELD(lwpstatus_t,	pr_syscall,	0);
173 	SCALAR_FIELD(lwpstatus_t,	pr_nsysarg,	0);
174 	SCALAR_FIELD(lwpstatus_t,	pr_errno,	0);
175 	ARRAY_FIELD(lwpstatus_t,	pr_sysarg,	0);
176 	SCALAR_FIELD(lwpstatus_t,	pr_rval1,	0);
177 	SCALAR_FIELD(lwpstatus_t,	pr_rval2,	0);
178 	ARRAY_FIELD(lwpstatus_t,	pr_clname,	0);
179 	SCALAR_FIELD(lwpstatus_t,	pr_tstamp,	0);
180 	SCALAR_FIELD(lwpstatus_t,	pr_utime,	0);
181 	SCALAR_FIELD(lwpstatus_t,	pr_stime,	0);
182 	SCALAR_FIELD(lwpstatus_t,	pr_errpriv,	0);
183 	SCALAR_FIELD(lwpstatus_t,	pr_ustack,	0);
184 	SCALAR_FIELD(lwpstatus_t,	pr_instr,	0);
185 	SCALAR_FIELD(lwpstatus_t,	pr_reg,		0);
186 	SCALAR_FIELD(lwpstatus_t,	pr_fpreg,	0);
187 
188 	END;
189 }
190 
191 
192 /* pstatus_t, <sys/procfs.h> */
193 static void
194 gen_pstatus(void)
195 {
196 	START(pstatus, pstatus_t);
197 
198 	SCALAR_FIELD(pstatus_t,		pr_flags,	1);
199 	SCALAR_FIELD(pstatus_t,		pr_nlwp,	1);
200 	SCALAR_FIELD(pstatus_t,		pr_pid,		0);
201 	SCALAR_FIELD(pstatus_t,		pr_ppid,	0);
202 	SCALAR_FIELD(pstatus_t,		pr_pgid,	0);
203 	SCALAR_FIELD(pstatus_t,		pr_sid,		0);
204 	SCALAR_FIELD(pstatus_t,		pr_aslwpid,	1);
205 	SCALAR_FIELD(pstatus_t,		pr_agentid,	1);
206 	SCALAR_FIELD(pstatus_t,		pr_sigpend,	0);
207 	SCALAR_FIELD(pstatus_t,		pr_brkbase,	0);
208 	SCALAR_FIELD(pstatus_t,		pr_brksize,	0);
209 	SCALAR_FIELD(pstatus_t,		pr_stkbase,	0);
210 	SCALAR_FIELD(pstatus_t,		pr_stksize,	0);
211 	SCALAR_FIELD(pstatus_t,		pr_utime,	0);
212 	SCALAR_FIELD(pstatus_t,		pr_stime,	0);
213 	SCALAR_FIELD(pstatus_t,		pr_cutime,	0);
214 	SCALAR_FIELD(pstatus_t,		pr_cstime,	0);
215 	SCALAR_FIELD(pstatus_t,		pr_sigtrace,	0);
216 	SCALAR_FIELD(pstatus_t,		pr_flttrace,	0);
217 	SCALAR_FIELD(pstatus_t,		pr_sysentry,	0);
218 	SCALAR_FIELD(pstatus_t,		pr_sysexit,	0);
219 	SCALAR_FIELD(pstatus_t,		pr_dmodel,	0);
220 	SCALAR_FIELD(pstatus_t,		pr_taskid,	1);
221 	SCALAR_FIELD(pstatus_t,		pr_projid,	1);
222 	SCALAR_FIELD(pstatus_t,		pr_nzomb,	1);
223 	SCALAR_FIELD(pstatus_t,		pr_zoneid,	1);
224 	SCALAR_FIELD(pstatus_t,		pr_lwp,		0);
225 
226 	END;
227 }
228 
229 
230 /* prstatus_t, <sys/old_procfs.h> */
231 static void
232 gen_prstatus(void)
233 {
234 	START(prstatus, prstatus_t);
235 
236 	SCALAR_FIELD(prstatus_t,	pr_flags,	1);
237 	SCALAR_FIELD(prstatus_t,	pr_why,		1);
238 	SCALAR_FIELD(prstatus_t,	pr_what,	1);
239 	SCALAR_FIELD(prstatus_t,	pr_info,	0);
240 	SCALAR_FIELD(prstatus_t,	pr_cursig,	1);
241 	SCALAR_FIELD(prstatus_t,	pr_nlwp,	0);
242 	SCALAR_FIELD(prstatus_t,	pr_sigpend,	0);
243 	SCALAR_FIELD(prstatus_t,	pr_sighold,	0);
244 	SCALAR_FIELD(prstatus_t,	pr_altstack,	0);
245 	SCALAR_FIELD(prstatus_t,	pr_action,	0);
246 	SCALAR_FIELD(prstatus_t,	pr_pid,		0);
247 	SCALAR_FIELD(prstatus_t,	pr_ppid,	0);
248 	SCALAR_FIELD(prstatus_t,	pr_pgrp,	0);
249 	SCALAR_FIELD(prstatus_t,	pr_sid,		0);
250 	SCALAR_FIELD(prstatus_t,	pr_utime,	0);
251 	SCALAR_FIELD(prstatus_t,	pr_stime,	0);
252 	SCALAR_FIELD(prstatus_t,	pr_cutime,	0);
253 	SCALAR_FIELD(prstatus_t,	pr_cstime,	0);
254 	ARRAY_FIELD(prstatus_t,		pr_clname,	0);
255 	SCALAR_FIELD(prstatus_t,	pr_syscall,	1);
256 	SCALAR_FIELD(prstatus_t,	pr_nsysarg,	1);
257 	ARRAY_FIELD(prstatus_t,		pr_sysarg,	1);
258 	SCALAR_FIELD(prstatus_t,	pr_who,		0);
259 	SCALAR_FIELD(prstatus_t,	pr_lwppend,	0);
260 	SCALAR_FIELD(prstatus_t,	pr_oldcontext,	0);
261 	SCALAR_FIELD(prstatus_t,	pr_brkbase,	0);
262 	SCALAR_FIELD(prstatus_t,	pr_brksize,	0);
263 	SCALAR_FIELD(prstatus_t,	pr_stkbase,	0);
264 	SCALAR_FIELD(prstatus_t,	pr_stksize,	0);
265 	SCALAR_FIELD(prstatus_t,	pr_processor,	1);
266 	SCALAR_FIELD(prstatus_t,	pr_bind,	1);
267 	SCALAR_FIELD(prstatus_t,	pr_instr,	1);
268 	SCALAR_FIELD(prstatus_t,	pr_reg,		0);
269 
270 	END;
271 }
272 
273 
274 /* psinfo_t, <sys/procfs.h> */
275 static void
276 gen_psinfo(void)
277 {
278 	START(psinfo, psinfo_t);
279 
280 	SCALAR_FIELD(psinfo_t,		pr_flag,	1);
281 	SCALAR_FIELD(psinfo_t,		pr_nlwp,	1);
282 	SCALAR_FIELD(psinfo_t,		pr_pid,		0);
283 	SCALAR_FIELD(psinfo_t,		pr_ppid,	0);
284 	SCALAR_FIELD(psinfo_t,		pr_pgid,	0);
285 	SCALAR_FIELD(psinfo_t,		pr_sid,		0);
286 	SCALAR_FIELD(psinfo_t,		pr_uid,		0);
287 	SCALAR_FIELD(psinfo_t,		pr_euid,	0);
288 	SCALAR_FIELD(psinfo_t,		pr_gid,		0);
289 	SCALAR_FIELD(psinfo_t,		pr_egid,	0);
290 	SCALAR_FIELD(psinfo_t,		pr_addr,	0);
291 	SCALAR_FIELD(psinfo_t,		pr_size,	0);
292 	SCALAR_FIELD(psinfo_t,		pr_rssize,	0);
293 	SCALAR_FIELD(psinfo_t,		pr_ttydev,	0);
294 	SCALAR_FIELD(psinfo_t,		pr_pctcpu,	0);
295 	SCALAR_FIELD(psinfo_t,		pr_pctmem,	0);
296 	SCALAR_FIELD(psinfo_t,		pr_start,	0);
297 	SCALAR_FIELD(psinfo_t,		pr_time,	0);
298 	SCALAR_FIELD(psinfo_t,		pr_ctime,	0);
299 	ARRAY_FIELD(psinfo_t,		pr_fname,	0);
300 	ARRAY_FIELD(psinfo_t,		pr_psargs,	0);
301 	SCALAR_FIELD(psinfo_t,		pr_wstat,	1);
302 	SCALAR_FIELD(psinfo_t,		pr_argc,	1);
303 	SCALAR_FIELD(psinfo_t,		pr_argv,	0);
304 	SCALAR_FIELD(psinfo_t,		pr_envp,	0);
305 	SCALAR_FIELD(psinfo_t,		pr_dmodel,	0);
306 	SCALAR_FIELD(psinfo_t,		pr_taskid,	0);
307 	SCALAR_FIELD(psinfo_t,		pr_projid,	0);
308 	SCALAR_FIELD(psinfo_t,		pr_nzomb,	1);
309 	SCALAR_FIELD(psinfo_t,		pr_poolid,	0);
310 	SCALAR_FIELD(psinfo_t,		pr_zoneid,	0);
311 	SCALAR_FIELD(psinfo_t,		pr_contract,	0);
312 	SCALAR_FIELD(psinfo_t,		pr_lwp,		0);
313 
314 	END;
315 }
316 
317 /* prpsinfo_t, <sys/old_procfs.h> */
318 static void
319 gen_prpsinfo(void)
320 {
321 	START(prpsinfo, prpsinfo_t);
322 
323 	SCALAR_FIELD(prpsinfo_t,	pr_state,	0);
324 	SCALAR_FIELD(prpsinfo_t,	pr_sname,	0);
325 	SCALAR_FIELD(prpsinfo_t,	pr_zomb,	0);
326 	SCALAR_FIELD(prpsinfo_t,	pr_nice,	0);
327 	SCALAR_FIELD(prpsinfo_t,	pr_flag,	0);
328 	SCALAR_FIELD(prpsinfo_t,	pr_uid,		0);
329 	SCALAR_FIELD(prpsinfo_t,	pr_gid,		0);
330 	SCALAR_FIELD(prpsinfo_t,	pr_pid,		0);
331 	SCALAR_FIELD(prpsinfo_t,	pr_ppid,	0);
332 	SCALAR_FIELD(prpsinfo_t,	pr_pgrp,	0);
333 	SCALAR_FIELD(prpsinfo_t,	pr_sid,		0);
334 	SCALAR_FIELD(prpsinfo_t,	pr_addr,	0);
335 	SCALAR_FIELD(prpsinfo_t,	pr_size,	0);
336 	SCALAR_FIELD(prpsinfo_t,	pr_rssize,	0);
337 	SCALAR_FIELD(prpsinfo_t,	pr_wchan,	0);
338 	SCALAR_FIELD(prpsinfo_t,	pr_start,	0);
339 	SCALAR_FIELD(prpsinfo_t,	pr_time,	0);
340 	SCALAR_FIELD(prpsinfo_t,	pr_pri,		1);
341 	SCALAR_FIELD(prpsinfo_t,	pr_oldpri,	0);
342 	SCALAR_FIELD(prpsinfo_t,	pr_cpu,		0);
343 	SCALAR_FIELD(prpsinfo_t,	pr_ottydev,	0);
344 	SCALAR_FIELD(prpsinfo_t,	pr_lttydev,	0);
345 	ARRAY_FIELD(prpsinfo_t,		pr_clname,	0);
346 	ARRAY_FIELD(prpsinfo_t,		pr_fname,	0);
347 	ARRAY_FIELD(prpsinfo_t,		pr_psargs,	0);
348 	SCALAR_FIELD(prpsinfo_t,	pr_syscall,	1);
349 	SCALAR_FIELD(prpsinfo_t,	pr_ctime,	0);
350 	SCALAR_FIELD(prpsinfo_t,	pr_bysize,	0);
351 	SCALAR_FIELD(prpsinfo_t,	pr_byrssize,	0);
352 	SCALAR_FIELD(prpsinfo_t,	pr_argc,	1);
353 	SCALAR_FIELD(prpsinfo_t,	pr_argv,	0);
354 	SCALAR_FIELD(prpsinfo_t,	pr_envp,	0);
355 	SCALAR_FIELD(prpsinfo_t,	pr_wstat,	1);
356 	SCALAR_FIELD(prpsinfo_t,	pr_pctcpu,	0);
357 	SCALAR_FIELD(prpsinfo_t,	pr_pctmem,	0);
358 	SCALAR_FIELD(prpsinfo_t,	pr_euid,	0);
359 	SCALAR_FIELD(prpsinfo_t,	pr_egid,	0);
360 	SCALAR_FIELD(prpsinfo_t,	pr_aslwpid,	0);
361 	SCALAR_FIELD(prpsinfo_t,	pr_dmodel,	0);
362 
363 	END;
364 }
365 
366 /* lwpsinfo_t, <sys/procfs.h> */
367 static void
368 gen_lwpsinfo(void)
369 {
370 	START(lwpsinfo, lwpsinfo_t);
371 
372 	SCALAR_FIELD(lwpsinfo_t,	pr_flag,	1);
373 	SCALAR_FIELD(lwpsinfo_t,	pr_lwpid,	0);
374 	SCALAR_FIELD(lwpsinfo_t,	pr_addr,	0);
375 	SCALAR_FIELD(lwpsinfo_t,	pr_wchan,	0);
376 	SCALAR_FIELD(lwpsinfo_t,	pr_stype,	0);
377 	SCALAR_FIELD(lwpsinfo_t,	pr_state,	0);
378 	SCALAR_FIELD(lwpsinfo_t,	pr_sname,	0);
379 	SCALAR_FIELD(lwpsinfo_t,	pr_nice,	0);
380 	SCALAR_FIELD(lwpsinfo_t,	pr_syscall,	0);
381 	SCALAR_FIELD(lwpsinfo_t,	pr_oldpri,	0);
382 	SCALAR_FIELD(lwpsinfo_t,	pr_cpu,		0);
383 	SCALAR_FIELD(lwpsinfo_t,	pr_pri,		1);
384 	SCALAR_FIELD(lwpsinfo_t,	pr_pctcpu,	0);
385 	SCALAR_FIELD(lwpsinfo_t,	pr_start,	0);
386 	SCALAR_FIELD(lwpsinfo_t,	pr_time,	0);
387 	ARRAY_FIELD(lwpsinfo_t,		pr_clname,	0);
388 	ARRAY_FIELD(lwpsinfo_t,		pr_name,	0);
389 	SCALAR_FIELD(lwpsinfo_t,	pr_onpro,	1);
390 	SCALAR_FIELD(lwpsinfo_t,	pr_bindpro,	1);
391 	SCALAR_FIELD(lwpsinfo_t,	pr_bindpset,	1);
392 	SCALAR_FIELD(lwpsinfo_t,	pr_lgrp,	1);
393 
394 	END;
395 }
396 
397 /* prcred_t, <sys/procfs.h> */
398 static void
399 gen_prcred(void)
400 {
401 	START(prcred, prcred_t);
402 
403 	SCALAR_FIELD(prcred_t,		pr_euid,	0);
404 	SCALAR_FIELD(prcred_t,		pr_ruid,	0);
405 	SCALAR_FIELD(prcred_t,		pr_suid,	0);
406 	SCALAR_FIELD(prcred_t,		pr_egid,	0);
407 	SCALAR_FIELD(prcred_t,		pr_rgid,	0);
408 	SCALAR_FIELD(prcred_t,		pr_sgid,	0);
409 	SCALAR_FIELD(prcred_t,		pr_ngroups,	1);
410 	ARRAY_FIELD(prcred_t,		pr_groups,	0);
411 
412 	END;
413 }
414 
415 /* prpriv_t, <sys/procfs.h> */
416 static void
417 gen_prpriv(void)
418 {
419 	START(prpriv, prpriv_t);
420 
421 	SCALAR_FIELD(prpriv_t,		pr_nsets,	0);
422 	SCALAR_FIELD(prpriv_t,		pr_setsize,	0);
423 	SCALAR_FIELD(prpriv_t,		pr_infosize,	0);
424 	ARRAY_FIELD(prpriv_t,		pr_sets,	0);
425 
426 	END;
427 }
428 
429 
430 /* priv_impl_info_t, <sys/priv.h> */
431 static void
432 gen_priv_impl_info(void)
433 {
434 	START(priv_impl_info, priv_impl_info_t);
435 
436 	SCALAR_FIELD(priv_impl_info_t,	priv_headersize,	0);
437 	SCALAR_FIELD(priv_impl_info_t,	priv_flags,		0);
438 	SCALAR_FIELD(priv_impl_info_t,	priv_nsets,		0);
439 	SCALAR_FIELD(priv_impl_info_t,	priv_setsize,		0);
440 	SCALAR_FIELD(priv_impl_info_t,	priv_max,		0);
441 	SCALAR_FIELD(priv_impl_info_t,	priv_infosize,		0);
442 	SCALAR_FIELD(priv_impl_info_t,	priv_globalinfosize,	0);
443 
444 	END;
445 }
446 
447 
448 /* fltset_t, <sys/fault.h> */
449 static void
450 gen_fltset(void)
451 {
452 	START(fltset, fltset_t);
453 
454 	ARRAY_FIELD(fltset_t,	word,	0);
455 
456 	END;
457 }
458 
459 /* Layout description of siginfo_t, <sys/siginfo.h> */
460 static void
461 gen_siginfo(void)
462 {
463 	START(siginfo, siginfo_t);
464 
465 	SCALAR_FIELD(siginfo_t,		si_signo,		0);
466 	SCALAR_FIELD(siginfo_t,		si_errno,		0);
467 	SCALAR_FIELD(siginfo_t,		si_code,		1);
468 	SCALAR_FIELD(siginfo_t,		si_value.sival_int,	0);
469 	SCALAR_FIELD(siginfo_t,		si_value.sival_ptr,	0);
470 	SCALAR_FIELD(siginfo_t,		si_pid,			0);
471 	SCALAR_FIELD(siginfo_t,		si_uid,			0);
472 	SCALAR_FIELD(siginfo_t,		si_ctid,		0);
473 	SCALAR_FIELD(siginfo_t,		si_zoneid,		0);
474 	SCALAR_FIELD(siginfo_t,		si_entity,		0);
475 	SCALAR_FIELD(siginfo_t,		si_addr,		0);
476 	SCALAR_FIELD(siginfo_t,		si_status,		0);
477 	SCALAR_FIELD(siginfo_t,		si_band,		0);
478 
479 	END;
480 }
481 
482 /* sigset_t, <sys/signal.h> */
483 static void
484 gen_sigset(void)
485 {
486 	START(sigset, sigset_t);
487 
488 	ARRAY_FIELD(sigset_t,	__sigbits,	0);
489 
490 	END;
491 }
492 
493 
494 /* struct sigaction, <sys/signal.h> */
495 static void
496 gen_sigaction(void)
497 {
498 	START(sigaction, struct sigaction);
499 
500 	SCALAR_FIELD(struct sigaction,	sa_flags,	0);
501 	SCALAR_FIELD(struct sigaction,	sa_handler,	0);
502 	SCALAR_FIELD(struct sigaction,	sa_sigaction,	0);
503 	SCALAR_FIELD(struct sigaction,	sa_mask,	0);
504 
505 	END;
506 }
507 
508 /* stack_t, <sys/signal.h> */
509 static void
510 gen_stack(void)
511 {
512 	START(stack, stack_t);
513 
514 	SCALAR_FIELD(stack_t,	ss_sp,		0);
515 	SCALAR_FIELD(stack_t,	ss_size,	0);
516 	SCALAR_FIELD(stack_t,	ss_flags,	0);
517 
518 	END;
519 }
520 
521 /* sysset_t, <sys/syscall.h> */
522 static void
523 gen_sysset(void)
524 {
525 	START(sysset, sysset_t);
526 
527 	ARRAY_FIELD(sysset_t,	word,	0);
528 
529 	END;
530 }
531 
532 /* timestruc_t, <sys/time_impl.h> */
533 static void
534 gen_timestruc(void)
535 {
536 	START(timestruc, timestruc_t);
537 
538 	SCALAR_FIELD(timestruc_t,	tv_sec,		0);
539 	SCALAR_FIELD(timestruc_t,	tv_nsec,	0);
540 
541 	END;
542 }
543 
544 /* struct utsname, <sys/utsname.h> */
545 static void
546 gen_utsname(void)
547 {
548 	START(utsname, struct utsname);
549 
550 	ARRAY_FIELD(struct utsname,	sysname,	0);
551 	ARRAY_FIELD(struct utsname,	nodename,	0);
552 	ARRAY_FIELD(struct utsname,	release,	0);
553 	ARRAY_FIELD(struct utsname,	version,	0);
554 	ARRAY_FIELD(struct utsname,	machine,	0);
555 
556 	END;
557 }
558 
559 
560 /*ARGSUSED*/
561 int
562 main(int argc, char *argv[])
563 {
564 	const char *fmt = "\t&%s_layout,\n";
565 
566 	printf("#include <struct_layout.h>\n");
567 
568 	gen_auxv();
569 	gen_prgregset();
570 	gen_lwpstatus();
571 	gen_pstatus();
572 	gen_prstatus();
573 	gen_psinfo();
574 	gen_prpsinfo();
575 	gen_lwpsinfo();
576 	gen_prcred();
577 	gen_prpriv();
578 	gen_priv_impl_info();
579 	gen_fltset();
580 	gen_siginfo();
581 	gen_sigset();
582 	gen_sigaction();
583 	gen_stack();
584 	gen_sysset();
585 	gen_timestruc();
586 	gen_utsname();
587 
588 
589 	/*
590 	 * Generate the full arch_layout description
591 	 */
592 	(void) printf(
593 	    "\n\n\n\nstatic const sl_arch_layout_t layout_%s = {\n",
594 	    MACH);
595 	(void) printf(fmt, "auxv");
596 	(void) printf(fmt, "fltset");
597 	(void) printf(fmt, "lwpsinfo");
598 	(void) printf(fmt, "lwpstatus");
599 	(void) printf(fmt, "prcred");
600 	(void) printf(fmt, "priv_impl_info");
601 	(void) printf(fmt, "prpriv");
602 	(void) printf(fmt, "psinfo");
603 	(void) printf(fmt, "pstatus");
604 	(void) printf(fmt, "prgregset");
605 	(void) printf(fmt, "prpsinfo");
606 	(void) printf(fmt, "prstatus");
607 	(void) printf(fmt, "sigaction");
608 	(void) printf(fmt, "siginfo");
609 	(void) printf(fmt, "sigset");
610 	(void) printf(fmt, "stack");
611 	(void) printf(fmt, "sysset");
612 	(void) printf(fmt, "timestruc");
613 	(void) printf(fmt, "utsname");
614 	(void) printf("};\n");
615 
616 	/*
617 	 * A public function, to make the information available
618 	 */
619 	(void) printf("\n\nconst sl_arch_layout_t *\n");
620 	(void) printf("struct_layout_%s(void)\n", MACH);
621 	(void) printf("{\n\treturn (&layout_%s);\n}\n", MACH);
622 
623 	return (0);
624 }
625