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