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