xref: /onnv-gate/usr/src/cmd/sgs/elfdump/common/struct_layout.h (revision 9273:9a0603d78ad3)
16635Sab196087 /*
26635Sab196087  * CDDL HEADER START
36635Sab196087  *
46635Sab196087  * The contents of this file are subject to the terms of the
56635Sab196087  * Common Development and Distribution License (the "License").
66635Sab196087  * You may not use this file except in compliance with the License.
76635Sab196087  *
86635Sab196087  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96635Sab196087  * or http://www.opensolaris.org/os/licensing.
106635Sab196087  * See the License for the specific language governing permissions
116635Sab196087  * and limitations under the License.
126635Sab196087  *
136635Sab196087  * When distributing Covered Code, include this CDDL HEADER in each
146635Sab196087  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156635Sab196087  * If applicable, add the following below this CDDL HEADER, with the
166635Sab196087  * fields enclosed by brackets "[]" replaced with your own identifying
176635Sab196087  * information: Portions Copyright [yyyy] [name of copyright owner]
186635Sab196087  *
196635Sab196087  * CDDL HEADER END
206635Sab196087  */
216635Sab196087 
226635Sab196087 /*
23*9273SAli.Bahrami@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
246635Sab196087  * Use is subject to license terms.
256635Sab196087  */
266635Sab196087 
276635Sab196087 #ifndef	_STRUCT_LAYOUT_H
286635Sab196087 #define	_STRUCT_LAYOUT_H
296635Sab196087 
306635Sab196087 #include	<conv.h>
316635Sab196087 #include	<_machelf.h>
326635Sab196087 
336635Sab196087 /*
346635Sab196087  * Local include file for elfdump, used to define structure layout
356635Sab196087  * definitions for various system structs.
366635Sab196087  */
376635Sab196087 
386635Sab196087 #ifdef	__cplusplus
396635Sab196087 extern "C" {
406635Sab196087 #endif
416635Sab196087 
426635Sab196087 
436635Sab196087 /*
446635Sab196087  * Solaris defines system structs that elfdump needs to display
456635Sab196087  * data from. We have a variety of hurdles to overcome in doing this:
466635Sab196087  *
476635Sab196087  *	- The size of system types can differ between ELFCLASS32 and
486635Sab196087  *		ELFCLASS64.
496635Sab196087  *	- Stucture layout can differ between architectures, so a given
506635Sab196087  *		field can have a different struct offset than is native
516635Sab196087  *		for the system running elfdump. Depending on the struct
526635Sab196087  *		in question, the layout for one platform may be impossible
536635Sab196087  *		to achieve on another.
546635Sab196087  *	- The byte order of the core object can differ from that
556635Sab196087  *		of the system running elfdump.
566635Sab196087  *
576635Sab196087  * The result is that in the fully general case, each architecture
586635Sab196087  * can have a slightly different definition of these structures.
596635Sab196087  * The usual approach of assigning a pointer of the desired structure
606635Sab196087  * type and then accessing fields through that pointer cannot be used
616635Sab196087  * here. That approach can only be used to access structures with the
626635Sab196087  * native layout of the elfdump host. We want any instance of elfdump
636635Sab196087  * to be able to examine a Solaris object for any supported architecture,
646635Sab196087  * so we need a more flexible approach.
656635Sab196087  *
666635Sab196087  * The solution to this problem lies in the fact that the binary
676635Sab196087  * layout of these public types cannot be changed, except in backward
686635Sab196087  * compatible ways. They are written to core files or published in
696635Sab196087  * other ways such that we can't make changes that would make it
706635Sab196087  * impossible to analyze old files. This means that we can build
716635Sab196087  * table of offsets and sizes for each field of each struct, on
726635Sab196087  * a per-archecture basis. These tables can be used to access the
736635Sab196087  * struct fields directly from the note desc data, and elfdump
746635Sab196087  * on any host can read the data from any other host.
756635Sab196087  *
766635Sab196087  * When reading these tables, it can be very helpful to examine
776635Sab196087  * the struct definition at the same time.
786635Sab196087  */
796635Sab196087 
806635Sab196087 /*
816635Sab196087  * sl_field_t is used to describe a struct field
826635Sab196087  */
836635Sab196087 typedef struct {
846635Sab196087 	ushort_t	slf_offset;	/* Offset from start of struct */
856635Sab196087 	ushort_t	slf_eltlen;	/* Size of datum, in bytes */
866635Sab196087 	ushort_t	slf_nelts;	/* 0 for scalar, # of els for array */
876635Sab196087 	uchar_t		slf_sign;	/* True (1) if signed quantity */
886635Sab196087 } sl_field_t;
896635Sab196087 
906635Sab196087 /*
916635Sab196087  * This type is used to extract and manipuate data described by
926635Sab196087  * sl_field_t. We rely on the C guarantee that all the fields in
936635Sab196087  * a union have offset 0.
946635Sab196087  */
956635Sab196087 typedef union {
966635Sab196087 	char		sld_i8;
976635Sab196087 	uchar_t 	sld_ui8;
986635Sab196087 	short		sld_i16;
996635Sab196087 	ushort_t	sld_ui16;
1006635Sab196087 	int32_t		sld_i32;
1016635Sab196087 	uint32_t	sld_ui32;
1026635Sab196087 	int64_t		sld_i64;
1036635Sab196087 	uint64_t	sld_ui64;
1046635Sab196087 } sl_data_t;
1056635Sab196087 
1066635Sab196087 /*
1076635Sab196087  * Buffer large enough to format any integral value in a field
1086635Sab196087  */
109*9273SAli.Bahrami@Sun.COM typedef char sl_fmtbuf_t[CONV_INV_BUFSIZE * 2];
1106635Sab196087 
1116635Sab196087 /*
1126635Sab196087  * Types of formatting done by fmt_num()
1136635Sab196087  */
1146635Sab196087 typedef enum {
1156635Sab196087 	SL_FMT_NUM_DEC = 0,	/* Decimal integer */
1166635Sab196087 	SL_FMT_NUM_HEX = 1,	/* Hex integer, with natural width */
1176635Sab196087 	SL_FMT_NUM_ZHEX = 2,	/* Hex integer, fixed width with zero fill  */
1186635Sab196087 } sl_fmt_num_t;
1196635Sab196087 
1206635Sab196087 
1216635Sab196087 
1226635Sab196087 
1236635Sab196087 /*
1246635Sab196087  * Layout description of auxv_t, from <sys/auxv.h>.
1256635Sab196087  */
1266635Sab196087 typedef struct {
1276635Sab196087 	sl_field_t		sizeof_struct;
1286635Sab196087 	sl_field_t		a_type;
1296635Sab196087 	sl_field_t		a_val;
1306635Sab196087 	sl_field_t		a_ptr;
1316635Sab196087 	sl_field_t		a_fcn;
1326635Sab196087 } sl_auxv_layout_t;
1336635Sab196087 
1346635Sab196087 /*
1356635Sab196087  * Layout description of prgregset_t, an architecture specific
1366635Sab196087  * array of general register c values
1376635Sab196087  */
1386635Sab196087 typedef struct {
1396635Sab196087 	sl_field_t		sizeof_struct;
1406635Sab196087 	sl_field_t		elt0;
1416635Sab196087 } sl_prgregset_layout_t;
1426635Sab196087 
1436635Sab196087 /*
1446635Sab196087  * Layout description of lwpstatus_t, from <sys/procfs.h>.
1456635Sab196087  */
1466635Sab196087 typedef struct {
1476635Sab196087 	sl_field_t		sizeof_struct;
1486635Sab196087 	sl_field_t		pr_flags;
1496635Sab196087 	sl_field_t		pr_lwpid;
1506635Sab196087 	sl_field_t		pr_why;
1516635Sab196087 	sl_field_t		pr_what;
1526635Sab196087 	sl_field_t		pr_cursig;
1536635Sab196087 	sl_field_t		pr_info;
1546635Sab196087 	sl_field_t		pr_lwppend;
1556635Sab196087 	sl_field_t		pr_lwphold;
1566635Sab196087 	sl_field_t		pr_action;
1576635Sab196087 	sl_field_t		pr_altstack;
1586635Sab196087 	sl_field_t		pr_oldcontext;
1596635Sab196087 	sl_field_t		pr_syscall;
1606635Sab196087 	sl_field_t		pr_nsysarg;
1616635Sab196087 	sl_field_t		pr_errno;
1626635Sab196087 	sl_field_t		pr_sysarg;
1636635Sab196087 	sl_field_t		pr_rval1;
1646635Sab196087 	sl_field_t		pr_rval2;
1656635Sab196087 	sl_field_t		pr_clname;
1666635Sab196087 	sl_field_t		pr_tstamp;
1676635Sab196087 	sl_field_t		pr_utime;
1686635Sab196087 	sl_field_t		pr_stime;
1696635Sab196087 	sl_field_t		pr_errpriv;
1706635Sab196087 	sl_field_t		pr_ustack;
1716635Sab196087 	sl_field_t		pr_instr;
1726635Sab196087 	sl_field_t		pr_reg;
1736635Sab196087 	sl_field_t		pr_fpreg;
1746635Sab196087 } sl_lwpstatus_layout_t;
1756635Sab196087 
1766635Sab196087 /*
1776635Sab196087  * Layout description of pstatus_t, from <sys/procfs.h>.
1786635Sab196087  */
1796635Sab196087 typedef struct {
1806635Sab196087 	sl_field_t		sizeof_struct;
1816635Sab196087 	sl_field_t		pr_flags;
1826635Sab196087 	sl_field_t		pr_nlwp;
1836635Sab196087 	sl_field_t		pr_pid;
1846635Sab196087 	sl_field_t		pr_ppid;
1856635Sab196087 	sl_field_t		pr_pgid;
1866635Sab196087 	sl_field_t		pr_sid;
1876635Sab196087 	sl_field_t		pr_aslwpid;
1886635Sab196087 	sl_field_t		pr_agentid;
1896635Sab196087 	sl_field_t		pr_sigpend;
1906635Sab196087 	sl_field_t		pr_brkbase;
1916635Sab196087 	sl_field_t		pr_brksize;
1926635Sab196087 	sl_field_t		pr_stkbase;
1936635Sab196087 	sl_field_t		pr_stksize;
1946635Sab196087 	sl_field_t		pr_utime;
1956635Sab196087 	sl_field_t		pr_stime;
1966635Sab196087 	sl_field_t		pr_cutime;
1976635Sab196087 	sl_field_t		pr_cstime;
1986635Sab196087 	sl_field_t		pr_sigtrace;
1996635Sab196087 	sl_field_t		pr_flttrace;
2006635Sab196087 	sl_field_t		pr_sysentry;
2016635Sab196087 	sl_field_t		pr_sysexit;
2026635Sab196087 	sl_field_t		pr_dmodel;
2036635Sab196087 	sl_field_t		pr_taskid;
2046635Sab196087 	sl_field_t		pr_projid;
2056635Sab196087 	sl_field_t		pr_nzomb;
2066635Sab196087 	sl_field_t		pr_zoneid;
2076635Sab196087 	sl_field_t		pr_lwp;
2086635Sab196087 } sl_pstatus_layout_t;
2096635Sab196087 
2106635Sab196087 /*
2116635Sab196087  * Layout description of prstatus_t, from <sys/old_procfs.h>.
2126635Sab196087  */
2136635Sab196087 typedef struct {
2146635Sab196087 	sl_field_t		sizeof_struct;
2156635Sab196087 	sl_field_t		pr_flags;
2166635Sab196087 	sl_field_t		pr_why;
2176635Sab196087 	sl_field_t		pr_what;
2186635Sab196087 	sl_field_t		pr_info;
2196635Sab196087 	sl_field_t		pr_cursig;
2206635Sab196087 	sl_field_t		pr_nlwp;
2216635Sab196087 	sl_field_t		pr_sigpend;
2226635Sab196087 	sl_field_t		pr_sighold;
2236635Sab196087 	sl_field_t		pr_altstack;
2246635Sab196087 	sl_field_t		pr_action;
2256635Sab196087 	sl_field_t		pr_pid;
2266635Sab196087 	sl_field_t		pr_ppid;
2276635Sab196087 	sl_field_t		pr_pgrp;
2286635Sab196087 	sl_field_t		pr_sid;
2296635Sab196087 	sl_field_t		pr_utime;
2306635Sab196087 	sl_field_t		pr_stime;
2316635Sab196087 	sl_field_t		pr_cutime;
2326635Sab196087 	sl_field_t		pr_cstime;
2336635Sab196087 	sl_field_t		pr_clname;
2346635Sab196087 	sl_field_t		pr_syscall;
2356635Sab196087 	sl_field_t		pr_nsysarg;
2366635Sab196087 	sl_field_t		pr_sysarg;
2376635Sab196087 	sl_field_t		pr_who;
2386635Sab196087 	sl_field_t		pr_lwppend;
2396635Sab196087 	sl_field_t		pr_oldcontext;
2406635Sab196087 	sl_field_t		pr_brkbase;
2416635Sab196087 	sl_field_t		pr_brksize;
2426635Sab196087 	sl_field_t		pr_stkbase;
2436635Sab196087 	sl_field_t		pr_stksize;
2446635Sab196087 	sl_field_t		pr_processor;
2456635Sab196087 	sl_field_t		pr_bind;
2466635Sab196087 	sl_field_t		pr_instr;
2476635Sab196087 	sl_field_t		pr_reg;
2486635Sab196087 } sl_prstatus_layout_t;
2496635Sab196087 
2506635Sab196087 /*
2516635Sab196087  * Layout description of psinfo_t, from <sys/procfs.h>.
2526635Sab196087  */
2536635Sab196087 typedef struct {
2546635Sab196087 	sl_field_t		sizeof_struct;
2556635Sab196087 	sl_field_t		pr_flag;
2566635Sab196087 	sl_field_t		pr_nlwp;
2576635Sab196087 	sl_field_t		pr_pid;
2586635Sab196087 	sl_field_t		pr_ppid;
2596635Sab196087 	sl_field_t		pr_pgid;
2606635Sab196087 	sl_field_t		pr_sid;
2616635Sab196087 	sl_field_t		pr_uid;
2626635Sab196087 	sl_field_t		pr_euid;
2636635Sab196087 	sl_field_t		pr_gid;
2646635Sab196087 	sl_field_t		pr_egid;
2656635Sab196087 	sl_field_t		pr_addr;
2666635Sab196087 	sl_field_t		pr_size;
2676635Sab196087 	sl_field_t		pr_rssize;
2686635Sab196087 	sl_field_t		pr_ttydev;
2696635Sab196087 	sl_field_t		pr_pctcpu;
2706635Sab196087 	sl_field_t		pr_pctmem;
2716635Sab196087 	sl_field_t		pr_start;
2726635Sab196087 	sl_field_t		pr_time;
2736635Sab196087 	sl_field_t		pr_ctime;
2746635Sab196087 	sl_field_t		pr_fname;
2756635Sab196087 	sl_field_t		pr_psargs;
2766635Sab196087 	sl_field_t		pr_wstat;
2776635Sab196087 	sl_field_t		pr_argc;
2786635Sab196087 	sl_field_t		pr_argv;
2796635Sab196087 	sl_field_t		pr_envp;
2806635Sab196087 	sl_field_t		pr_dmodel;
2816635Sab196087 	sl_field_t		pr_taskid;
2826635Sab196087 	sl_field_t		pr_projid;
2836635Sab196087 	sl_field_t		pr_nzomb;
2846635Sab196087 	sl_field_t		pr_poolid;
2856635Sab196087 	sl_field_t		pr_zoneid;
2866635Sab196087 	sl_field_t		pr_contract;
2876635Sab196087 	sl_field_t		pr_lwp;
2886635Sab196087 } sl_psinfo_layout_t;
2896635Sab196087 
2906635Sab196087 /*
2916635Sab196087  * Layout description of prpsinfo_t, from <sys/old_procfs.h>.
2926635Sab196087  */
2936635Sab196087 typedef struct {
2946635Sab196087 	sl_field_t		sizeof_struct;
2956635Sab196087 	sl_field_t		pr_state;
2966635Sab196087 	sl_field_t		pr_sname;
2976635Sab196087 	sl_field_t		pr_zomb;
2986635Sab196087 	sl_field_t		pr_nice;
2996635Sab196087 	sl_field_t		pr_flag;
3006635Sab196087 	sl_field_t		pr_uid;
3016635Sab196087 	sl_field_t		pr_gid;
3026635Sab196087 	sl_field_t		pr_pid;
3036635Sab196087 	sl_field_t		pr_ppid;
3046635Sab196087 	sl_field_t		pr_pgrp;
3056635Sab196087 	sl_field_t		pr_sid;
3066635Sab196087 	sl_field_t		pr_addr;
3076635Sab196087 	sl_field_t		pr_size;
3086635Sab196087 	sl_field_t		pr_rssize;
3096635Sab196087 	sl_field_t		pr_wchan;
3106635Sab196087 	sl_field_t		pr_start;
3116635Sab196087 	sl_field_t		pr_time;
3126635Sab196087 	sl_field_t		pr_pri;
3136635Sab196087 	sl_field_t		pr_oldpri;
3146635Sab196087 	sl_field_t		pr_cpu;
3156635Sab196087 	sl_field_t		pr_ottydev;
3166635Sab196087 	sl_field_t		pr_lttydev;
3176635Sab196087 	sl_field_t		pr_clname;
3186635Sab196087 	sl_field_t		pr_fname;
3196635Sab196087 	sl_field_t		pr_psargs;
3206635Sab196087 	sl_field_t		pr_syscall;
3216635Sab196087 	sl_field_t		pr_ctime;
3226635Sab196087 	sl_field_t		pr_bysize;
3236635Sab196087 	sl_field_t		pr_byrssize;
3246635Sab196087 	sl_field_t		pr_argc;
3256635Sab196087 	sl_field_t		pr_argv;
3266635Sab196087 	sl_field_t		pr_envp;
3276635Sab196087 	sl_field_t		pr_wstat;
3286635Sab196087 	sl_field_t		pr_pctcpu;
3296635Sab196087 	sl_field_t		pr_pctmem;
3306635Sab196087 	sl_field_t		pr_euid;
3316635Sab196087 	sl_field_t		pr_egid;
3326635Sab196087 	sl_field_t		pr_aslwpid;
3336635Sab196087 	sl_field_t		pr_dmodel;
3346635Sab196087 } sl_prpsinfo_layout_t;
3356635Sab196087 
3366635Sab196087 /*
3376635Sab196087  * Layout description of lwpsinfo_t, from <sys/procfs.h>.
3386635Sab196087  */
3396635Sab196087 typedef struct {
3406635Sab196087 	sl_field_t		sizeof_struct;
3416635Sab196087 	sl_field_t		pr_flag;
3426635Sab196087 	sl_field_t		pr_lwpid;
3436635Sab196087 	sl_field_t		pr_addr;
3446635Sab196087 	sl_field_t		pr_wchan;
3456635Sab196087 	sl_field_t		pr_stype;
3466635Sab196087 	sl_field_t		pr_state;
3476635Sab196087 	sl_field_t		pr_sname;
3486635Sab196087 	sl_field_t		pr_nice;
3496635Sab196087 	sl_field_t		pr_syscall;
3506635Sab196087 	sl_field_t		pr_oldpri;
3516635Sab196087 	sl_field_t		pr_cpu;
3526635Sab196087 	sl_field_t		pr_pri;
3536635Sab196087 	sl_field_t		pr_pctcpu;
3546635Sab196087 	sl_field_t		pr_start;
3556635Sab196087 	sl_field_t		pr_time;
3566635Sab196087 	sl_field_t		pr_clname;
3576635Sab196087 	sl_field_t		pr_name;
3586635Sab196087 	sl_field_t		pr_onpro;
3596635Sab196087 	sl_field_t		pr_bindpro;
3606635Sab196087 	sl_field_t		pr_bindpset;
3616635Sab196087 	sl_field_t		pr_lgrp;
3626635Sab196087 } sl_lwpsinfo_layout_t;
3636635Sab196087 
3646635Sab196087 /*
3656635Sab196087  * Layout description of prcred_t, from <sys/procfs.h>.
3666635Sab196087  */
3676635Sab196087 typedef struct {
3686635Sab196087 	sl_field_t		sizeof_struct;
3696635Sab196087 	sl_field_t		pr_euid;
3706635Sab196087 	sl_field_t		pr_ruid;
3716635Sab196087 	sl_field_t		pr_suid;
3726635Sab196087 	sl_field_t		pr_egid;
3736635Sab196087 	sl_field_t		pr_rgid;
3746635Sab196087 	sl_field_t		pr_sgid;
3756635Sab196087 	sl_field_t		pr_ngroups;
3766635Sab196087 	sl_field_t		pr_groups;
3776635Sab196087 } sl_prcred_layout_t;
3786635Sab196087 
3796635Sab196087 /*
3806635Sab196087  * Layout description of prpriv_t, from <sys/procfs.h>.
3816635Sab196087  */
3826635Sab196087 typedef struct {
3836635Sab196087 	sl_field_t		sizeof_struct;
3846635Sab196087 	sl_field_t		pr_nsets;
3856635Sab196087 	sl_field_t		pr_setsize;
3866635Sab196087 	sl_field_t		pr_infosize;
3876635Sab196087 	sl_field_t		pr_sets;
3886635Sab196087 } sl_prpriv_layout_t;
3896635Sab196087 
3906635Sab196087 /*
3916635Sab196087  * Layout description of priv_impl_info_t, from <sys/priv.h>.
3926635Sab196087  */
3936635Sab196087 typedef struct {
3946635Sab196087 	sl_field_t		sizeof_struct;
3956635Sab196087 	sl_field_t		priv_headersize;
3966635Sab196087 	sl_field_t		priv_flags;
3976635Sab196087 	sl_field_t		priv_nsets;
3986635Sab196087 	sl_field_t		priv_setsize;
3996635Sab196087 	sl_field_t		priv_max;
4006635Sab196087 	sl_field_t		priv_infosize;
4016635Sab196087 	sl_field_t		priv_globalinfosize;
4026635Sab196087 } sl_priv_impl_info_layout_t;
4036635Sab196087 
4046635Sab196087 /*
4056635Sab196087  * Layout description of fltset_t, from <sys/fault.h>.
4066635Sab196087  */
4076635Sab196087 typedef struct {
4086635Sab196087 	sl_field_t		sizeof_struct;
4096635Sab196087 	sl_field_t		word;
4106635Sab196087 } sl_fltset_layout_t;
4116635Sab196087 
4126635Sab196087 /*
4136635Sab196087  * Layout description of siginfo_t, from <sys/siginfo.h>.
4146635Sab196087  *
4156635Sab196087  * siginfo_t is unusual, in that it contains a large union
4166635Sab196087  * full of private fields. There are macros defined to give
4176635Sab196087  * access to these fields via the names documented in the
4186635Sab196087  * siginfo manpage. We stick to the documented names
4196635Sab196087  * rather than try to unravel the undocumented blob. Hence,
4206635Sab196087  * the layout description below is a "logical" view of siginfo_t.
4216635Sab196087  * The fields below are not necessarily in the same order as
4226635Sab196087  * they appear in siginfo_t, nor are they everything that is in
4236635Sab196087  * that struct. They may also overlap each other, if they are
4246635Sab196087  * contained within of the union.
4256635Sab196087  *
4266635Sab196087  * The f_ prefixes are used to prevent our field names from
4276635Sab196087  * clashing with the macros defined in siginfo.h.
4286635Sab196087  */
4296635Sab196087 typedef struct {
4306635Sab196087 	sl_field_t		sizeof_struct;
4316635Sab196087 	sl_field_t		f_si_signo;
4326635Sab196087 	sl_field_t		f_si_errno;
4336635Sab196087 	sl_field_t		f_si_code;
4346635Sab196087 	sl_field_t		f_si_value_int;
4356635Sab196087 	sl_field_t		f_si_value_ptr;
4366635Sab196087 	sl_field_t		f_si_pid;
4376635Sab196087 	sl_field_t		f_si_uid;
4386635Sab196087 	sl_field_t		f_si_ctid;
4396635Sab196087 	sl_field_t		f_si_zoneid;
4406635Sab196087 	sl_field_t		f_si_entity;
4416635Sab196087 	sl_field_t		f_si_addr;
4426635Sab196087 	sl_field_t		f_si_status;
4436635Sab196087 	sl_field_t		f_si_band;
4446635Sab196087 } sl_siginfo_layout_t;
4456635Sab196087 
4466635Sab196087 /*
4476635Sab196087  * Layout description of sigset_t, from <sys/signal.h>.
4486635Sab196087  */
4496635Sab196087 typedef struct {
4506635Sab196087 	sl_field_t		sizeof_struct;
4516635Sab196087 	sl_field_t		sigbits;
4526635Sab196087 } sl_sigset_layout_t;
4536635Sab196087 
4546635Sab196087 /*
4556635Sab196087  * Layout description of struct sigaction, from <sys/signal.h>.
4566635Sab196087  */
4576635Sab196087 typedef struct {
4586635Sab196087 	sl_field_t		sizeof_struct;
4596635Sab196087 	sl_field_t		sa_flags;
4606635Sab196087 	sl_field_t		sa_hand;
4616635Sab196087 	sl_field_t		sa_sigact;
4626635Sab196087 	sl_field_t		sa_mask;
4636635Sab196087 } sl_sigaction_layout_t;
4646635Sab196087 
4656635Sab196087 /*
4666635Sab196087  * Layout description of stack_t, from <sys/signal.h>.
4676635Sab196087  */
4686635Sab196087 typedef struct {
4696635Sab196087 	sl_field_t		sizeof_struct;
4706635Sab196087 	sl_field_t		ss_sp;
4716635Sab196087 	sl_field_t		ss_size;
4726635Sab196087 	sl_field_t		ss_flags;
4736635Sab196087 } sl_stack_layout_t;
4746635Sab196087 
4756635Sab196087 /*
4766635Sab196087  * Layout description of sysset_t, from <sys/syscall.h>.
4776635Sab196087  */
4786635Sab196087 typedef struct {
4796635Sab196087 	sl_field_t		sizeof_struct;
4806635Sab196087 	sl_field_t		word;
4816635Sab196087 } sl_sysset_layout_t;
4826635Sab196087 
4836635Sab196087 /*
4846635Sab196087  * Layout description of timestruc_t, from <sys/time_impl.h>.
4856635Sab196087  */
4866635Sab196087 typedef struct {
4876635Sab196087 	sl_field_t		sizeof_struct;
4886635Sab196087 	sl_field_t		tv_sec;
4896635Sab196087 	sl_field_t		tv_nsec;
4906635Sab196087 } sl_timestruc_layout_t;
4916635Sab196087 
4926635Sab196087 /*
4936635Sab196087  * Layout description of struct utsname, from <sys/utsname.h>.
4946635Sab196087  */
4956635Sab196087 typedef struct {
4966635Sab196087 	sl_field_t		sizeof_struct;
4976635Sab196087 	sl_field_t		sysname;
4986635Sab196087 	sl_field_t		nodename;
4996635Sab196087 	sl_field_t		release;
5006635Sab196087 	sl_field_t		version;
5016635Sab196087 	sl_field_t		machine;
5026635Sab196087 } sl_utsname_layout_t;
5036635Sab196087 
5046635Sab196087 /*
5056635Sab196087  * This type collects all of the layout definitions for
5066635Sab196087  * a given architecture.
5076635Sab196087  */
5086635Sab196087 typedef struct {
5096635Sab196087 	const sl_auxv_layout_t		*auxv;		/* auxv_t */
5106635Sab196087 	const sl_fltset_layout_t	*fltset;	/* fltset_t */
5116635Sab196087 	const sl_lwpsinfo_layout_t	*lwpsinfo;	/* lwpsinfo_t */
5126635Sab196087 	const sl_lwpstatus_layout_t	*lwpstatus;	/* lwpstatus_t */
5136635Sab196087 	const sl_prcred_layout_t	*prcred;	/* prcred_t */
5146635Sab196087 	const sl_priv_impl_info_layout_t *priv_impl_info; /* priv_impl_info_t */
5156635Sab196087 	const sl_prpriv_layout_t	*prpriv;	/* prpriv_t */
5166635Sab196087 	const sl_psinfo_layout_t	*psinfo;	/* psinfo_t */
5176635Sab196087 	const sl_pstatus_layout_t	*pstatus;	/* pstatus_t */
5186635Sab196087 	const sl_prgregset_layout_t	*prgregset;	/* prgregset_t */
5196635Sab196087 	const sl_prpsinfo_layout_t	*prpsinfo;	/* prpsinfo_t */
5206635Sab196087 	const sl_prstatus_layout_t	*prstatus;	/* prstatus_t */
5216635Sab196087 	const sl_sigaction_layout_t	*sigaction;	/* struct sigaction */
5226635Sab196087 	const sl_siginfo_layout_t	*siginfo;	/* siginfo_t */
5236635Sab196087 	const sl_sigset_layout_t	*sigset;	/* sigset_t */
5246635Sab196087 	const sl_stack_layout_t		*stack;		/* stack_t */
5256635Sab196087 	const sl_sysset_layout_t	*sysset;	/* sysset_t */
5266635Sab196087 	const sl_timestruc_layout_t	*timestruc;	/* timestruc_t */
5276635Sab196087 	const sl_utsname_layout_t	*utsname;	/* struct utsname */
5286635Sab196087 } sl_arch_layout_t;
5296635Sab196087 
5306635Sab196087 
5316635Sab196087 
5326635Sab196087 extern	void		sl_extract_num_field(const char *data, int do_swap,
5336635Sab196087 			    const sl_field_t *fdesc, sl_data_t *field_data);
5346635Sab196087 extern	Word		sl_extract_as_word(const char *data, int do_swap,
5356635Sab196087 			    const sl_field_t *fdesc);
5366635Sab196087 extern	Lword		sl_extract_as_lword(const char *data, int do_swap,
5376635Sab196087 			    const sl_field_t *fdesc);
5386635Sab196087 extern	Sword		sl_extract_as_sword(const char *data, int do_swap,
5396635Sab196087 			    const sl_field_t *fdesc);
5406635Sab196087 extern	const char	*sl_fmt_num(const char *data, int do_swap,
5416635Sab196087 			    const sl_field_t *fdesc, sl_fmt_num_t fmt_type,
5426635Sab196087 			    sl_fmtbuf_t buf);
5436635Sab196087 
5446635Sab196087 
5456635Sab196087 extern	const sl_arch_layout_t	*sl_mach(Half);
5466635Sab196087 extern	const sl_arch_layout_t	*struct_layout_i386(void);
5476635Sab196087 extern	const sl_arch_layout_t	*struct_layout_amd64(void);
5486635Sab196087 extern	const sl_arch_layout_t	*struct_layout_sparc(void);
5496635Sab196087 extern	const sl_arch_layout_t	*struct_layout_sparcv9(void);
5506635Sab196087 
5516635Sab196087 
5526635Sab196087 
5536635Sab196087 #ifdef	__cplusplus
5546635Sab196087 }
5556635Sab196087 #endif
5566635Sab196087 
5576635Sab196087 #endif	/* _STRUCT_LAYOUT_H */
558