xref: /onnv-gate/usr/src/cmd/sgs/elfdump/common/struct_layout.h (revision 6635:8de60a34b2e5)
1*6635Sab196087 /*
2*6635Sab196087  * CDDL HEADER START
3*6635Sab196087  *
4*6635Sab196087  * The contents of this file are subject to the terms of the
5*6635Sab196087  * Common Development and Distribution License (the "License").
6*6635Sab196087  * You may not use this file except in compliance with the License.
7*6635Sab196087  *
8*6635Sab196087  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*6635Sab196087  * or http://www.opensolaris.org/os/licensing.
10*6635Sab196087  * See the License for the specific language governing permissions
11*6635Sab196087  * and limitations under the License.
12*6635Sab196087  *
13*6635Sab196087  * When distributing Covered Code, include this CDDL HEADER in each
14*6635Sab196087  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*6635Sab196087  * If applicable, add the following below this CDDL HEADER, with the
16*6635Sab196087  * fields enclosed by brackets "[]" replaced with your own identifying
17*6635Sab196087  * information: Portions Copyright [yyyy] [name of copyright owner]
18*6635Sab196087  *
19*6635Sab196087  * CDDL HEADER END
20*6635Sab196087  */
21*6635Sab196087 
22*6635Sab196087 /*
23*6635Sab196087  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24*6635Sab196087  * Use is subject to license terms.
25*6635Sab196087  */
26*6635Sab196087 
27*6635Sab196087 #ifndef	_STRUCT_LAYOUT_H
28*6635Sab196087 #define	_STRUCT_LAYOUT_H
29*6635Sab196087 
30*6635Sab196087 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*6635Sab196087 
32*6635Sab196087 #include	<conv.h>
33*6635Sab196087 #include	<_machelf.h>
34*6635Sab196087 
35*6635Sab196087 /*
36*6635Sab196087  * Local include file for elfdump, used to define structure layout
37*6635Sab196087  * definitions for various system structs.
38*6635Sab196087  */
39*6635Sab196087 
40*6635Sab196087 #ifdef	__cplusplus
41*6635Sab196087 extern "C" {
42*6635Sab196087 #endif
43*6635Sab196087 
44*6635Sab196087 
45*6635Sab196087 /*
46*6635Sab196087  * Solaris defines system structs that elfdump needs to display
47*6635Sab196087  * data from. We have a variety of hurdles to overcome in doing this:
48*6635Sab196087  *
49*6635Sab196087  *	- The size of system types can differ between ELFCLASS32 and
50*6635Sab196087  *		ELFCLASS64.
51*6635Sab196087  *	- Stucture layout can differ between architectures, so a given
52*6635Sab196087  *		field can have a different struct offset than is native
53*6635Sab196087  *		for the system running elfdump. Depending on the struct
54*6635Sab196087  *		in question, the layout for one platform may be impossible
55*6635Sab196087  *		to achieve on another.
56*6635Sab196087  *	- The byte order of the core object can differ from that
57*6635Sab196087  *		of the system running elfdump.
58*6635Sab196087  *
59*6635Sab196087  * The result is that in the fully general case, each architecture
60*6635Sab196087  * can have a slightly different definition of these structures.
61*6635Sab196087  * The usual approach of assigning a pointer of the desired structure
62*6635Sab196087  * type and then accessing fields through that pointer cannot be used
63*6635Sab196087  * here. That approach can only be used to access structures with the
64*6635Sab196087  * native layout of the elfdump host. We want any instance of elfdump
65*6635Sab196087  * to be able to examine a Solaris object for any supported architecture,
66*6635Sab196087  * so we need a more flexible approach.
67*6635Sab196087  *
68*6635Sab196087  * The solution to this problem lies in the fact that the binary
69*6635Sab196087  * layout of these public types cannot be changed, except in backward
70*6635Sab196087  * compatible ways. They are written to core files or published in
71*6635Sab196087  * other ways such that we can't make changes that would make it
72*6635Sab196087  * impossible to analyze old files. This means that we can build
73*6635Sab196087  * table of offsets and sizes for each field of each struct, on
74*6635Sab196087  * a per-archecture basis. These tables can be used to access the
75*6635Sab196087  * struct fields directly from the note desc data, and elfdump
76*6635Sab196087  * on any host can read the data from any other host.
77*6635Sab196087  *
78*6635Sab196087  * When reading these tables, it can be very helpful to examine
79*6635Sab196087  * the struct definition at the same time.
80*6635Sab196087  */
81*6635Sab196087 
82*6635Sab196087 /*
83*6635Sab196087  * sl_field_t is used to describe a struct field
84*6635Sab196087  */
85*6635Sab196087 typedef struct {
86*6635Sab196087 	ushort_t	slf_offset;	/* Offset from start of struct */
87*6635Sab196087 	ushort_t	slf_eltlen;	/* Size of datum, in bytes */
88*6635Sab196087 	ushort_t	slf_nelts;	/* 0 for scalar, # of els for array */
89*6635Sab196087 	uchar_t		slf_sign;	/* True (1) if signed quantity */
90*6635Sab196087 } sl_field_t;
91*6635Sab196087 
92*6635Sab196087 /*
93*6635Sab196087  * This type is used to extract and manipuate data described by
94*6635Sab196087  * sl_field_t. We rely on the C guarantee that all the fields in
95*6635Sab196087  * a union have offset 0.
96*6635Sab196087  */
97*6635Sab196087 typedef union {
98*6635Sab196087 	char		sld_i8;
99*6635Sab196087 	uchar_t 	sld_ui8;
100*6635Sab196087 	short		sld_i16;
101*6635Sab196087 	ushort_t	sld_ui16;
102*6635Sab196087 	int32_t		sld_i32;
103*6635Sab196087 	uint32_t	sld_ui32;
104*6635Sab196087 	int64_t		sld_i64;
105*6635Sab196087 	uint64_t	sld_ui64;
106*6635Sab196087 } sl_data_t;
107*6635Sab196087 
108*6635Sab196087 /*
109*6635Sab196087  * Buffer large enough to format any integral value in a field
110*6635Sab196087  */
111*6635Sab196087 typedef char sl_fmtbuf_t[CONV64_INV_BUFSIZE * 2];
112*6635Sab196087 
113*6635Sab196087 /*
114*6635Sab196087  * Types of formatting done by fmt_num()
115*6635Sab196087  */
116*6635Sab196087 typedef enum {
117*6635Sab196087 	SL_FMT_NUM_DEC = 0,	/* Decimal integer */
118*6635Sab196087 	SL_FMT_NUM_HEX = 1,	/* Hex integer, with natural width */
119*6635Sab196087 	SL_FMT_NUM_ZHEX = 2,	/* Hex integer, fixed width with zero fill  */
120*6635Sab196087 } sl_fmt_num_t;
121*6635Sab196087 
122*6635Sab196087 
123*6635Sab196087 
124*6635Sab196087 
125*6635Sab196087 /*
126*6635Sab196087  * Layout description of auxv_t, from <sys/auxv.h>.
127*6635Sab196087  */
128*6635Sab196087 typedef struct {
129*6635Sab196087 	sl_field_t		sizeof_struct;
130*6635Sab196087 	sl_field_t		a_type;
131*6635Sab196087 	sl_field_t		a_val;
132*6635Sab196087 	sl_field_t		a_ptr;
133*6635Sab196087 	sl_field_t		a_fcn;
134*6635Sab196087 } sl_auxv_layout_t;
135*6635Sab196087 
136*6635Sab196087 /*
137*6635Sab196087  * Layout description of prgregset_t, an architecture specific
138*6635Sab196087  * array of general register c values
139*6635Sab196087  */
140*6635Sab196087 typedef struct {
141*6635Sab196087 	sl_field_t		sizeof_struct;
142*6635Sab196087 	sl_field_t		elt0;
143*6635Sab196087 } sl_prgregset_layout_t;
144*6635Sab196087 
145*6635Sab196087 /*
146*6635Sab196087  * Layout description of lwpstatus_t, from <sys/procfs.h>.
147*6635Sab196087  */
148*6635Sab196087 typedef struct {
149*6635Sab196087 	sl_field_t		sizeof_struct;
150*6635Sab196087 	sl_field_t		pr_flags;
151*6635Sab196087 	sl_field_t		pr_lwpid;
152*6635Sab196087 	sl_field_t		pr_why;
153*6635Sab196087 	sl_field_t		pr_what;
154*6635Sab196087 	sl_field_t		pr_cursig;
155*6635Sab196087 	sl_field_t		pr_info;
156*6635Sab196087 	sl_field_t		pr_lwppend;
157*6635Sab196087 	sl_field_t		pr_lwphold;
158*6635Sab196087 	sl_field_t		pr_action;
159*6635Sab196087 	sl_field_t		pr_altstack;
160*6635Sab196087 	sl_field_t		pr_oldcontext;
161*6635Sab196087 	sl_field_t		pr_syscall;
162*6635Sab196087 	sl_field_t		pr_nsysarg;
163*6635Sab196087 	sl_field_t		pr_errno;
164*6635Sab196087 	sl_field_t		pr_sysarg;
165*6635Sab196087 	sl_field_t		pr_rval1;
166*6635Sab196087 	sl_field_t		pr_rval2;
167*6635Sab196087 	sl_field_t		pr_clname;
168*6635Sab196087 	sl_field_t		pr_tstamp;
169*6635Sab196087 	sl_field_t		pr_utime;
170*6635Sab196087 	sl_field_t		pr_stime;
171*6635Sab196087 	sl_field_t		pr_errpriv;
172*6635Sab196087 	sl_field_t		pr_ustack;
173*6635Sab196087 	sl_field_t		pr_instr;
174*6635Sab196087 	sl_field_t		pr_reg;
175*6635Sab196087 	sl_field_t		pr_fpreg;
176*6635Sab196087 } sl_lwpstatus_layout_t;
177*6635Sab196087 
178*6635Sab196087 /*
179*6635Sab196087  * Layout description of pstatus_t, from <sys/procfs.h>.
180*6635Sab196087  */
181*6635Sab196087 typedef struct {
182*6635Sab196087 	sl_field_t		sizeof_struct;
183*6635Sab196087 	sl_field_t		pr_flags;
184*6635Sab196087 	sl_field_t		pr_nlwp;
185*6635Sab196087 	sl_field_t		pr_pid;
186*6635Sab196087 	sl_field_t		pr_ppid;
187*6635Sab196087 	sl_field_t		pr_pgid;
188*6635Sab196087 	sl_field_t		pr_sid;
189*6635Sab196087 	sl_field_t		pr_aslwpid;
190*6635Sab196087 	sl_field_t		pr_agentid;
191*6635Sab196087 	sl_field_t		pr_sigpend;
192*6635Sab196087 	sl_field_t		pr_brkbase;
193*6635Sab196087 	sl_field_t		pr_brksize;
194*6635Sab196087 	sl_field_t		pr_stkbase;
195*6635Sab196087 	sl_field_t		pr_stksize;
196*6635Sab196087 	sl_field_t		pr_utime;
197*6635Sab196087 	sl_field_t		pr_stime;
198*6635Sab196087 	sl_field_t		pr_cutime;
199*6635Sab196087 	sl_field_t		pr_cstime;
200*6635Sab196087 	sl_field_t		pr_sigtrace;
201*6635Sab196087 	sl_field_t		pr_flttrace;
202*6635Sab196087 	sl_field_t		pr_sysentry;
203*6635Sab196087 	sl_field_t		pr_sysexit;
204*6635Sab196087 	sl_field_t		pr_dmodel;
205*6635Sab196087 	sl_field_t		pr_taskid;
206*6635Sab196087 	sl_field_t		pr_projid;
207*6635Sab196087 	sl_field_t		pr_nzomb;
208*6635Sab196087 	sl_field_t		pr_zoneid;
209*6635Sab196087 	sl_field_t		pr_lwp;
210*6635Sab196087 } sl_pstatus_layout_t;
211*6635Sab196087 
212*6635Sab196087 /*
213*6635Sab196087  * Layout description of prstatus_t, from <sys/old_procfs.h>.
214*6635Sab196087  */
215*6635Sab196087 typedef struct {
216*6635Sab196087 	sl_field_t		sizeof_struct;
217*6635Sab196087 	sl_field_t		pr_flags;
218*6635Sab196087 	sl_field_t		pr_why;
219*6635Sab196087 	sl_field_t		pr_what;
220*6635Sab196087 	sl_field_t		pr_info;
221*6635Sab196087 	sl_field_t		pr_cursig;
222*6635Sab196087 	sl_field_t		pr_nlwp;
223*6635Sab196087 	sl_field_t		pr_sigpend;
224*6635Sab196087 	sl_field_t		pr_sighold;
225*6635Sab196087 	sl_field_t		pr_altstack;
226*6635Sab196087 	sl_field_t		pr_action;
227*6635Sab196087 	sl_field_t		pr_pid;
228*6635Sab196087 	sl_field_t		pr_ppid;
229*6635Sab196087 	sl_field_t		pr_pgrp;
230*6635Sab196087 	sl_field_t		pr_sid;
231*6635Sab196087 	sl_field_t		pr_utime;
232*6635Sab196087 	sl_field_t		pr_stime;
233*6635Sab196087 	sl_field_t		pr_cutime;
234*6635Sab196087 	sl_field_t		pr_cstime;
235*6635Sab196087 	sl_field_t		pr_clname;
236*6635Sab196087 	sl_field_t		pr_syscall;
237*6635Sab196087 	sl_field_t		pr_nsysarg;
238*6635Sab196087 	sl_field_t		pr_sysarg;
239*6635Sab196087 	sl_field_t		pr_who;
240*6635Sab196087 	sl_field_t		pr_lwppend;
241*6635Sab196087 	sl_field_t		pr_oldcontext;
242*6635Sab196087 	sl_field_t		pr_brkbase;
243*6635Sab196087 	sl_field_t		pr_brksize;
244*6635Sab196087 	sl_field_t		pr_stkbase;
245*6635Sab196087 	sl_field_t		pr_stksize;
246*6635Sab196087 	sl_field_t		pr_processor;
247*6635Sab196087 	sl_field_t		pr_bind;
248*6635Sab196087 	sl_field_t		pr_instr;
249*6635Sab196087 	sl_field_t		pr_reg;
250*6635Sab196087 } sl_prstatus_layout_t;
251*6635Sab196087 
252*6635Sab196087 /*
253*6635Sab196087  * Layout description of psinfo_t, from <sys/procfs.h>.
254*6635Sab196087  */
255*6635Sab196087 typedef struct {
256*6635Sab196087 	sl_field_t		sizeof_struct;
257*6635Sab196087 	sl_field_t		pr_flag;
258*6635Sab196087 	sl_field_t		pr_nlwp;
259*6635Sab196087 	sl_field_t		pr_pid;
260*6635Sab196087 	sl_field_t		pr_ppid;
261*6635Sab196087 	sl_field_t		pr_pgid;
262*6635Sab196087 	sl_field_t		pr_sid;
263*6635Sab196087 	sl_field_t		pr_uid;
264*6635Sab196087 	sl_field_t		pr_euid;
265*6635Sab196087 	sl_field_t		pr_gid;
266*6635Sab196087 	sl_field_t		pr_egid;
267*6635Sab196087 	sl_field_t		pr_addr;
268*6635Sab196087 	sl_field_t		pr_size;
269*6635Sab196087 	sl_field_t		pr_rssize;
270*6635Sab196087 	sl_field_t		pr_ttydev;
271*6635Sab196087 	sl_field_t		pr_pctcpu;
272*6635Sab196087 	sl_field_t		pr_pctmem;
273*6635Sab196087 	sl_field_t		pr_start;
274*6635Sab196087 	sl_field_t		pr_time;
275*6635Sab196087 	sl_field_t		pr_ctime;
276*6635Sab196087 	sl_field_t		pr_fname;
277*6635Sab196087 	sl_field_t		pr_psargs;
278*6635Sab196087 	sl_field_t		pr_wstat;
279*6635Sab196087 	sl_field_t		pr_argc;
280*6635Sab196087 	sl_field_t		pr_argv;
281*6635Sab196087 	sl_field_t		pr_envp;
282*6635Sab196087 	sl_field_t		pr_dmodel;
283*6635Sab196087 	sl_field_t		pr_taskid;
284*6635Sab196087 	sl_field_t		pr_projid;
285*6635Sab196087 	sl_field_t		pr_nzomb;
286*6635Sab196087 	sl_field_t		pr_poolid;
287*6635Sab196087 	sl_field_t		pr_zoneid;
288*6635Sab196087 	sl_field_t		pr_contract;
289*6635Sab196087 	sl_field_t		pr_lwp;
290*6635Sab196087 } sl_psinfo_layout_t;
291*6635Sab196087 
292*6635Sab196087 /*
293*6635Sab196087  * Layout description of prpsinfo_t, from <sys/old_procfs.h>.
294*6635Sab196087  */
295*6635Sab196087 typedef struct {
296*6635Sab196087 	sl_field_t		sizeof_struct;
297*6635Sab196087 	sl_field_t		pr_state;
298*6635Sab196087 	sl_field_t		pr_sname;
299*6635Sab196087 	sl_field_t		pr_zomb;
300*6635Sab196087 	sl_field_t		pr_nice;
301*6635Sab196087 	sl_field_t		pr_flag;
302*6635Sab196087 	sl_field_t		pr_uid;
303*6635Sab196087 	sl_field_t		pr_gid;
304*6635Sab196087 	sl_field_t		pr_pid;
305*6635Sab196087 	sl_field_t		pr_ppid;
306*6635Sab196087 	sl_field_t		pr_pgrp;
307*6635Sab196087 	sl_field_t		pr_sid;
308*6635Sab196087 	sl_field_t		pr_addr;
309*6635Sab196087 	sl_field_t		pr_size;
310*6635Sab196087 	sl_field_t		pr_rssize;
311*6635Sab196087 	sl_field_t		pr_wchan;
312*6635Sab196087 	sl_field_t		pr_start;
313*6635Sab196087 	sl_field_t		pr_time;
314*6635Sab196087 	sl_field_t		pr_pri;
315*6635Sab196087 	sl_field_t		pr_oldpri;
316*6635Sab196087 	sl_field_t		pr_cpu;
317*6635Sab196087 	sl_field_t		pr_ottydev;
318*6635Sab196087 	sl_field_t		pr_lttydev;
319*6635Sab196087 	sl_field_t		pr_clname;
320*6635Sab196087 	sl_field_t		pr_fname;
321*6635Sab196087 	sl_field_t		pr_psargs;
322*6635Sab196087 	sl_field_t		pr_syscall;
323*6635Sab196087 	sl_field_t		pr_ctime;
324*6635Sab196087 	sl_field_t		pr_bysize;
325*6635Sab196087 	sl_field_t		pr_byrssize;
326*6635Sab196087 	sl_field_t		pr_argc;
327*6635Sab196087 	sl_field_t		pr_argv;
328*6635Sab196087 	sl_field_t		pr_envp;
329*6635Sab196087 	sl_field_t		pr_wstat;
330*6635Sab196087 	sl_field_t		pr_pctcpu;
331*6635Sab196087 	sl_field_t		pr_pctmem;
332*6635Sab196087 	sl_field_t		pr_euid;
333*6635Sab196087 	sl_field_t		pr_egid;
334*6635Sab196087 	sl_field_t		pr_aslwpid;
335*6635Sab196087 	sl_field_t		pr_dmodel;
336*6635Sab196087 } sl_prpsinfo_layout_t;
337*6635Sab196087 
338*6635Sab196087 /*
339*6635Sab196087  * Layout description of lwpsinfo_t, from <sys/procfs.h>.
340*6635Sab196087  */
341*6635Sab196087 typedef struct {
342*6635Sab196087 	sl_field_t		sizeof_struct;
343*6635Sab196087 	sl_field_t		pr_flag;
344*6635Sab196087 	sl_field_t		pr_lwpid;
345*6635Sab196087 	sl_field_t		pr_addr;
346*6635Sab196087 	sl_field_t		pr_wchan;
347*6635Sab196087 	sl_field_t		pr_stype;
348*6635Sab196087 	sl_field_t		pr_state;
349*6635Sab196087 	sl_field_t		pr_sname;
350*6635Sab196087 	sl_field_t		pr_nice;
351*6635Sab196087 	sl_field_t		pr_syscall;
352*6635Sab196087 	sl_field_t		pr_oldpri;
353*6635Sab196087 	sl_field_t		pr_cpu;
354*6635Sab196087 	sl_field_t		pr_pri;
355*6635Sab196087 	sl_field_t		pr_pctcpu;
356*6635Sab196087 	sl_field_t		pr_start;
357*6635Sab196087 	sl_field_t		pr_time;
358*6635Sab196087 	sl_field_t		pr_clname;
359*6635Sab196087 	sl_field_t		pr_name;
360*6635Sab196087 	sl_field_t		pr_onpro;
361*6635Sab196087 	sl_field_t		pr_bindpro;
362*6635Sab196087 	sl_field_t		pr_bindpset;
363*6635Sab196087 	sl_field_t		pr_lgrp;
364*6635Sab196087 } sl_lwpsinfo_layout_t;
365*6635Sab196087 
366*6635Sab196087 /*
367*6635Sab196087  * Layout description of prcred_t, from <sys/procfs.h>.
368*6635Sab196087  */
369*6635Sab196087 typedef struct {
370*6635Sab196087 	sl_field_t		sizeof_struct;
371*6635Sab196087 	sl_field_t		pr_euid;
372*6635Sab196087 	sl_field_t		pr_ruid;
373*6635Sab196087 	sl_field_t		pr_suid;
374*6635Sab196087 	sl_field_t		pr_egid;
375*6635Sab196087 	sl_field_t		pr_rgid;
376*6635Sab196087 	sl_field_t		pr_sgid;
377*6635Sab196087 	sl_field_t		pr_ngroups;
378*6635Sab196087 	sl_field_t		pr_groups;
379*6635Sab196087 } sl_prcred_layout_t;
380*6635Sab196087 
381*6635Sab196087 /*
382*6635Sab196087  * Layout description of prpriv_t, from <sys/procfs.h>.
383*6635Sab196087  */
384*6635Sab196087 typedef struct {
385*6635Sab196087 	sl_field_t		sizeof_struct;
386*6635Sab196087 	sl_field_t		pr_nsets;
387*6635Sab196087 	sl_field_t		pr_setsize;
388*6635Sab196087 	sl_field_t		pr_infosize;
389*6635Sab196087 	sl_field_t		pr_sets;
390*6635Sab196087 } sl_prpriv_layout_t;
391*6635Sab196087 
392*6635Sab196087 /*
393*6635Sab196087  * Layout description of priv_impl_info_t, from <sys/priv.h>.
394*6635Sab196087  */
395*6635Sab196087 typedef struct {
396*6635Sab196087 	sl_field_t		sizeof_struct;
397*6635Sab196087 	sl_field_t		priv_headersize;
398*6635Sab196087 	sl_field_t		priv_flags;
399*6635Sab196087 	sl_field_t		priv_nsets;
400*6635Sab196087 	sl_field_t		priv_setsize;
401*6635Sab196087 	sl_field_t		priv_max;
402*6635Sab196087 	sl_field_t		priv_infosize;
403*6635Sab196087 	sl_field_t		priv_globalinfosize;
404*6635Sab196087 } sl_priv_impl_info_layout_t;
405*6635Sab196087 
406*6635Sab196087 /*
407*6635Sab196087  * Layout description of fltset_t, from <sys/fault.h>.
408*6635Sab196087  */
409*6635Sab196087 typedef struct {
410*6635Sab196087 	sl_field_t		sizeof_struct;
411*6635Sab196087 	sl_field_t		word;
412*6635Sab196087 } sl_fltset_layout_t;
413*6635Sab196087 
414*6635Sab196087 /*
415*6635Sab196087  * Layout description of siginfo_t, from <sys/siginfo.h>.
416*6635Sab196087  *
417*6635Sab196087  * siginfo_t is unusual, in that it contains a large union
418*6635Sab196087  * full of private fields. There are macros defined to give
419*6635Sab196087  * access to these fields via the names documented in the
420*6635Sab196087  * siginfo manpage. We stick to the documented names
421*6635Sab196087  * rather than try to unravel the undocumented blob. Hence,
422*6635Sab196087  * the layout description below is a "logical" view of siginfo_t.
423*6635Sab196087  * The fields below are not necessarily in the same order as
424*6635Sab196087  * they appear in siginfo_t, nor are they everything that is in
425*6635Sab196087  * that struct. They may also overlap each other, if they are
426*6635Sab196087  * contained within of the union.
427*6635Sab196087  *
428*6635Sab196087  * The f_ prefixes are used to prevent our field names from
429*6635Sab196087  * clashing with the macros defined in siginfo.h.
430*6635Sab196087  */
431*6635Sab196087 typedef struct {
432*6635Sab196087 	sl_field_t		sizeof_struct;
433*6635Sab196087 	sl_field_t		f_si_signo;
434*6635Sab196087 	sl_field_t		f_si_errno;
435*6635Sab196087 	sl_field_t		f_si_code;
436*6635Sab196087 	sl_field_t		f_si_value_int;
437*6635Sab196087 	sl_field_t		f_si_value_ptr;
438*6635Sab196087 	sl_field_t		f_si_pid;
439*6635Sab196087 	sl_field_t		f_si_uid;
440*6635Sab196087 	sl_field_t		f_si_ctid;
441*6635Sab196087 	sl_field_t		f_si_zoneid;
442*6635Sab196087 	sl_field_t		f_si_entity;
443*6635Sab196087 	sl_field_t		f_si_addr;
444*6635Sab196087 	sl_field_t		f_si_status;
445*6635Sab196087 	sl_field_t		f_si_band;
446*6635Sab196087 } sl_siginfo_layout_t;
447*6635Sab196087 
448*6635Sab196087 /*
449*6635Sab196087  * Layout description of sigset_t, from <sys/signal.h>.
450*6635Sab196087  */
451*6635Sab196087 typedef struct {
452*6635Sab196087 	sl_field_t		sizeof_struct;
453*6635Sab196087 	sl_field_t		sigbits;
454*6635Sab196087 } sl_sigset_layout_t;
455*6635Sab196087 
456*6635Sab196087 /*
457*6635Sab196087  * Layout description of struct sigaction, from <sys/signal.h>.
458*6635Sab196087  */
459*6635Sab196087 typedef struct {
460*6635Sab196087 	sl_field_t		sizeof_struct;
461*6635Sab196087 	sl_field_t		sa_flags;
462*6635Sab196087 	sl_field_t		sa_hand;
463*6635Sab196087 	sl_field_t		sa_sigact;
464*6635Sab196087 	sl_field_t		sa_mask;
465*6635Sab196087 } sl_sigaction_layout_t;
466*6635Sab196087 
467*6635Sab196087 /*
468*6635Sab196087  * Layout description of stack_t, from <sys/signal.h>.
469*6635Sab196087  */
470*6635Sab196087 typedef struct {
471*6635Sab196087 	sl_field_t		sizeof_struct;
472*6635Sab196087 	sl_field_t		ss_sp;
473*6635Sab196087 	sl_field_t		ss_size;
474*6635Sab196087 	sl_field_t		ss_flags;
475*6635Sab196087 } sl_stack_layout_t;
476*6635Sab196087 
477*6635Sab196087 /*
478*6635Sab196087  * Layout description of sysset_t, from <sys/syscall.h>.
479*6635Sab196087  */
480*6635Sab196087 typedef struct {
481*6635Sab196087 	sl_field_t		sizeof_struct;
482*6635Sab196087 	sl_field_t		word;
483*6635Sab196087 } sl_sysset_layout_t;
484*6635Sab196087 
485*6635Sab196087 /*
486*6635Sab196087  * Layout description of timestruc_t, from <sys/time_impl.h>.
487*6635Sab196087  */
488*6635Sab196087 typedef struct {
489*6635Sab196087 	sl_field_t		sizeof_struct;
490*6635Sab196087 	sl_field_t		tv_sec;
491*6635Sab196087 	sl_field_t		tv_nsec;
492*6635Sab196087 } sl_timestruc_layout_t;
493*6635Sab196087 
494*6635Sab196087 /*
495*6635Sab196087  * Layout description of struct utsname, from <sys/utsname.h>.
496*6635Sab196087  */
497*6635Sab196087 typedef struct {
498*6635Sab196087 	sl_field_t		sizeof_struct;
499*6635Sab196087 	sl_field_t		sysname;
500*6635Sab196087 	sl_field_t		nodename;
501*6635Sab196087 	sl_field_t		release;
502*6635Sab196087 	sl_field_t		version;
503*6635Sab196087 	sl_field_t		machine;
504*6635Sab196087 } sl_utsname_layout_t;
505*6635Sab196087 
506*6635Sab196087 /*
507*6635Sab196087  * This type collects all of the layout definitions for
508*6635Sab196087  * a given architecture.
509*6635Sab196087  */
510*6635Sab196087 typedef struct {
511*6635Sab196087 	const sl_auxv_layout_t		*auxv;		/* auxv_t */
512*6635Sab196087 	const sl_fltset_layout_t	*fltset;	/* fltset_t */
513*6635Sab196087 	const sl_lwpsinfo_layout_t	*lwpsinfo;	/* lwpsinfo_t */
514*6635Sab196087 	const sl_lwpstatus_layout_t	*lwpstatus;	/* lwpstatus_t */
515*6635Sab196087 	const sl_prcred_layout_t	*prcred;	/* prcred_t */
516*6635Sab196087 	const sl_priv_impl_info_layout_t *priv_impl_info; /* priv_impl_info_t */
517*6635Sab196087 	const sl_prpriv_layout_t	*prpriv;	/* prpriv_t */
518*6635Sab196087 	const sl_psinfo_layout_t	*psinfo;	/* psinfo_t */
519*6635Sab196087 	const sl_pstatus_layout_t	*pstatus;	/* pstatus_t */
520*6635Sab196087 	const sl_prgregset_layout_t	*prgregset;	/* prgregset_t */
521*6635Sab196087 	const sl_prpsinfo_layout_t	*prpsinfo;	/* prpsinfo_t */
522*6635Sab196087 	const sl_prstatus_layout_t	*prstatus;	/* prstatus_t */
523*6635Sab196087 	const sl_sigaction_layout_t	*sigaction;	/* struct sigaction */
524*6635Sab196087 	const sl_siginfo_layout_t	*siginfo;	/* siginfo_t */
525*6635Sab196087 	const sl_sigset_layout_t	*sigset;	/* sigset_t */
526*6635Sab196087 	const sl_stack_layout_t		*stack;		/* stack_t */
527*6635Sab196087 	const sl_sysset_layout_t	*sysset;	/* sysset_t */
528*6635Sab196087 	const sl_timestruc_layout_t	*timestruc;	/* timestruc_t */
529*6635Sab196087 	const sl_utsname_layout_t	*utsname;	/* struct utsname */
530*6635Sab196087 } sl_arch_layout_t;
531*6635Sab196087 
532*6635Sab196087 
533*6635Sab196087 
534*6635Sab196087 extern	void		sl_extract_num_field(const char *data, int do_swap,
535*6635Sab196087 			    const sl_field_t *fdesc, sl_data_t *field_data);
536*6635Sab196087 extern	Word		sl_extract_as_word(const char *data, int do_swap,
537*6635Sab196087 			    const sl_field_t *fdesc);
538*6635Sab196087 extern	Lword		sl_extract_as_lword(const char *data, int do_swap,
539*6635Sab196087 			    const sl_field_t *fdesc);
540*6635Sab196087 extern	Sword		sl_extract_as_sword(const char *data, int do_swap,
541*6635Sab196087 			    const sl_field_t *fdesc);
542*6635Sab196087 extern	const char	*sl_fmt_num(const char *data, int do_swap,
543*6635Sab196087 			    const sl_field_t *fdesc, sl_fmt_num_t fmt_type,
544*6635Sab196087 			    sl_fmtbuf_t buf);
545*6635Sab196087 
546*6635Sab196087 
547*6635Sab196087 extern	const sl_arch_layout_t	*sl_mach(Half);
548*6635Sab196087 extern	const sl_arch_layout_t	*struct_layout_i386(void);
549*6635Sab196087 extern	const sl_arch_layout_t	*struct_layout_amd64(void);
550*6635Sab196087 extern	const sl_arch_layout_t	*struct_layout_sparc(void);
551*6635Sab196087 extern	const sl_arch_layout_t	*struct_layout_sparcv9(void);
552*6635Sab196087 
553*6635Sab196087 
554*6635Sab196087 
555*6635Sab196087 #ifdef	__cplusplus
556*6635Sab196087 }
557*6635Sab196087 #endif
558*6635Sab196087 
559*6635Sab196087 #endif	/* _STRUCT_LAYOUT_H */
560