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