/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
*/
#ifndef _STRUCT_LAYOUT_H
#define _STRUCT_LAYOUT_H
#include <conv.h>
#include <_machelf.h>
/*
* Local include file for elfdump, used to define structure layout
* definitions for various system structs.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Solaris defines system structs that elfdump needs to display
* data from. We have a variety of hurdles to overcome in doing this:
*
* - The size of system types can differ between ELFCLASS32 and
* ELFCLASS64.
* - Stucture layout can differ between architectures, so a given
* field can have a different struct offset than is native
* for the system running elfdump. Depending on the struct
* in question, the layout for one platform may be impossible
* to achieve on another.
* - The byte order of the core object can differ from that
* of the system running elfdump.
*
* The result is that in the fully general case, each architecture
* can have a slightly different definition of these structures.
* The usual approach of assigning a pointer of the desired structure
* type and then accessing fields through that pointer cannot be used
* here. That approach can only be used to access structures with the
* native layout of the elfdump host. We want any instance of elfdump
* to be able to examine a Solaris object for any supported architecture,
* so we need a more flexible approach.
*
* The solution to this problem lies in the fact that the binary
* layout of these public types cannot be changed, except in backward
* compatible ways. They are written to core files or published in
* other ways such that we can't make changes that would make it
* impossible to analyze old files. This means that we can build
* table of offsets and sizes for each field of each struct, on
* a per-archecture basis. These tables can be used to access the
* struct fields directly from the note desc data, and elfdump
* on any host can read the data from any other host.
*
* When reading these tables, it can be very helpful to examine
* the struct definition at the same time.
*/
/*
* sl_field_t is used to describe a struct field
*/
typedef struct {
} sl_field_t;
/*
* This type is used to extract and manipulate data described by
* sl_field_t. We rely on the C guarantee that all the fields in
* a union have offset 0.
*/
typedef union {
char sld_i8;
short sld_i16;
} sl_data_t;
/*
* Buffer large enough to format any integral value in a field
*/
/*
* Types of formatting done by fmt_num()
*/
typedef enum {
} sl_fmt_num_t;
/*
*/
typedef struct {
/*
* Layout description of prgregset_t, an architecture specific
* array of general register c values
*/
typedef struct {
/*
*/
typedef struct {
/*
*/
typedef struct {
/*
* Layout description of prstatus_t, from <sys/old_procfs.h>.
*/
typedef struct {
/*
*/
typedef struct {
/*
* Layout description of prpsinfo_t, from <sys/old_procfs.h>.
*/
typedef struct {
/*
*/
typedef struct {
/*
*/
typedef struct {
/*
*/
typedef struct {
/*
*/
typedef struct {
/*
*/
typedef struct {
/*
*
* siginfo_t is unusual, in that it contains a large union
* full of private fields. There are macros defined to give
* access to these fields via the names documented in the
* siginfo manpage. We stick to the documented names
* rather than try to unravel the undocumented blob. Hence,
* the layout description below is a "logical" view of siginfo_t.
* The fields below are not necessarily in the same order as
* they appear in siginfo_t, nor are they everything that is in
* that struct. They may also overlap each other, if they are
* contained within of the union.
*
* The f_ prefixes are used to prevent our field names from
* clashing with the macros defined in siginfo.h.
*/
typedef struct {
/*
*/
typedef struct {
/*
*/
typedef struct {
/*
*/
typedef struct {
/*
*/
typedef struct {
/*
* Layout description of timestruc_t, from <sys/time_impl.h>.
*/
typedef struct {
/*
*/
typedef struct {
/*
*/
typedef struct {
typedef struct {
/*
* This type collects all of the layout definitions for
* a given architecture.
*/
typedef struct {
const sl_field_t *fdesc);
const sl_field_t *fdesc);
const sl_field_t *fdesc);
extern const sl_arch_layout_t *struct_layout_i386(void);
extern const sl_arch_layout_t *struct_layout_amd64(void);
extern const sl_arch_layout_t *struct_layout_sparc(void);
extern const sl_arch_layout_t *struct_layout_sparcv9(void);
#ifdef __cplusplus
}
#endif
#endif /* _STRUCT_LAYOUT_H */