_elfdump.h revision c6c9aed4d309e3d11be652b85e3bf8bb72f20c87
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef __ELFDUMP_H
#define __ELFDUMP_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <_machelf.h>
#include <debug.h>
/*
* Local include file for elfdump.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* flags: This is a bitmask that controls elfdump's operations. There
* are three categories of flag:
*
* SHOW - Specify categories of things in the ELF object to display.
* CALC - Compute something based on the contents of the ELF object.
* CTL - Control options specify general options that are not
* specific to any specific part of the ELF object, but
* which apply at a higher level.
*
* To simplify masking these categories, they are assigned bit ranges
* as follows:
* SHOW: Bottom 24-bits
* CALC: Upper nibble of most significant byte
* CTL: Lower nibble of most significant byte
*/
#define FLG_SHOW_DYNAMIC 0x00000001
#define FLG_SHOW_EHDR 0x00000002
#define FLG_SHOW_INTERP 0x00000004
#define FLG_SHOW_SHDR 0x00000008
#define FLG_SHOW_NOTE 0x00000010
#define FLG_SHOW_PHDR 0x00000020
#define FLG_SHOW_RELOC 0x00000040
#define FLG_SHOW_SYMBOLS 0x00000080
#define FLG_SHOW_VERSIONS 0x00000100
#define FLG_SHOW_HASH 0x00000200
#define FLG_SHOW_GOT 0x00000400
#define FLG_SHOW_SYMINFO 0x00000800
#define FLG_SHOW_MOVE 0x00001000
#define FLG_SHOW_GROUP 0x00002000
#define FLG_SHOW_CAP 0x00004000
#define FLG_SHOW_UNWIND 0x00008000
#define FLG_SHOW_SORT 0x00010000
#define FLG_CTL_LONGNAME 0x01000000
#define FLG_CTL_DEMANGLE 0x02000000
#define FLG_CTL_FAKESHDR 0x04000000
#define FLG_CTL_MATCH 0x08000000
#define FLG_CALC_CHECKSUM 0x10000000
/* Bitmasks that isolate the parts of a flag value */
#define FLG_MASK_SHOW 0x00ffffff
#define FLG_MASK_CTL 0x0f000000
#define FLG_MASK_CALC 0xf0000000
/*
* Mask that selects the show flags that do not require the ELF
* object to have a section header array.
*/
/*
* Masks to select the flags that require the ELF object to
* have a section header array, within each flag type.
*/
#define FLG_MASK_CALC_SHDR FLG_CALC_CHECKSUM
/* Size of buffer used for formatting an index into textual representation */
#define MAXNDXSIZE 10
typedef struct cache {
char *c_name;
int c_ndx; /* Section index */
} Cache;
typedef struct got_info {
/* support mixed relocations */
void *g_rel;
const char *g_symname;
} Got_info;
extern const Cache cache_init;
extern void failure(const char *, const char *);
/*
* Flags for the match() function:
* MATCH_F_STRICT
* A strict match requires an explicit match to
* a user specified match (-I, -N, -T) option. A
* non-strict match also succeeds if the match
* list is empty.
*
* MATCH_F_PHDR
* The match item is a program header. If this
* flag is not set, the match item is a section
* header.
*
* MATCH_F_NAME
* The name parameter contains valid information.
*
* MATCH_F_NDX
* The ndx argument contains valid information
*
* MATCH_F_TYPE
* The type argument contains valid information
*/
typedef enum {
MATCH_F_STRICT = 1,
MATCH_F_PHDR = 2,
MATCH_F_NAME = 4,
MATCH_F_NDX = 8,
MATCH_F_TYPE = 16
/* It is common for calls to match() to specify all three arguments */
/*
* Possible return values from corenote()
*/
typedef enum {
CORENOTE_R_OK = 0, /* Note data successfully displayed */
/* support for given architecture */
/*
* Define various elfdump() functions into their 32-bit and 64-bit variants.
*/
#if defined(_ELF64)
#define checksum checksum64
#define fake_shdr_cache fake_shdr_cache64
#define note_entry note_entry64
#define sections sections64
#define symlookup symlookup64
#define versions versions64
#define version_def version_def64
#define version_need version_need64
#else
#define checksum checksum32
#define fake_shdr_cache fake_shdr_cache32
#define note_entry note_entry32
#define sections sections32
#define symlookup symlookup32
#define versions versions32
#define version_def version_def32
#define version_need version_need32
#endif
extern void dump_hex_bytes(const char *, size_t, int, int, int);
#ifdef __cplusplus
}
#endif
#endif /* __ELFDUMP_H */