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