5aefb6555731130ca4fd295960123d71f2d21fe8rie * CDDL HEADER START
5aefb6555731130ca4fd295960123d71f2d21fe8rie * The contents of this file are subject to the terms of the
5aefb6555731130ca4fd295960123d71f2d21fe8rie * Common Development and Distribution License (the "License").
5aefb6555731130ca4fd295960123d71f2d21fe8rie * You may not use this file except in compliance with the License.
5aefb6555731130ca4fd295960123d71f2d21fe8rie * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5aefb6555731130ca4fd295960123d71f2d21fe8rie * See the License for the specific language governing permissions
5aefb6555731130ca4fd295960123d71f2d21fe8rie * and limitations under the License.
5aefb6555731130ca4fd295960123d71f2d21fe8rie * When distributing Covered Code, include this CDDL HEADER in each
5aefb6555731130ca4fd295960123d71f2d21fe8rie * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5aefb6555731130ca4fd295960123d71f2d21fe8rie * If applicable, add the following below this CDDL HEADER, with the
5aefb6555731130ca4fd295960123d71f2d21fe8rie * fields enclosed by brackets "[]" replaced with your own identifying
5aefb6555731130ca4fd295960123d71f2d21fe8rie * information: Portions Copyright [yyyy] [name of copyright owner]
5aefb6555731130ca4fd295960123d71f2d21fe8rie * CDDL HEADER END
7e16fca05dfbcfd32c2ebc9e4d1abdac1cd8657cAli Bahrami * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5aefb6555731130ca4fd295960123d71f2d21fe8rie * Use is subject to license terms.
ba2be53024c0b999e74ba9adcd7d80fec5df8c57ab#include <_machelf.h>
5aefb6555731130ca4fd295960123d71f2d21fe8rie * Local include file for elfdump.
5aefb6555731130ca4fd295960123d71f2d21fe8rieextern "C" {
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * flags: This is a bitmask that controls elfdump's operations. There
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * are three categories of flag:
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * SHOW - Specify categories of things in the ELF object to display.
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * CALC - Compute something based on the contents of the ELF object.
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * CTL - Control options specify general options that are not
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * specific to any specific part of the ELF object, but
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * which apply at a higher level.
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * To simplify masking these categories, they are assigned bit ranges
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * as follows:
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * SHOW: Bottom 24-bits
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * CALC: Upper 2 bits of most significant byte
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * CTL: Lower 6 bits of most significant byte
981a172d53aeb81520fcfecf6ab2615277c7bd18ab/* Bitmasks that isolate the parts of a flag value */
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * Mask that selects the show flags that do not require the ELF
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * object to have a section header array.
981a172d53aeb81520fcfecf6ab2615277c7bd18ab#define FLG_MASK_SHOW_NOSHDR (FLG_SHOW_EHDR | FLG_SHOW_PHDR)
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * Masks to select the flags that require the ELF object to
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * have a section header array, within each flag type.
981a172d53aeb81520fcfecf6ab2615277c7bd18ab#define FLG_MASK_SHOW_SHDR (FLG_MASK_SHOW & ~FLG_MASK_SHOW_NOSHDR)
981a172d53aeb81520fcfecf6ab2615277c7bd18ab/* Size of buffer used for formatting an index into textual representation */
5aefb6555731130ca4fd295960123d71f2d21fe8rie /* support mixed relocations */
5aefb6555731130ca4fd295960123d71f2d21fe8rieextern void failure(const char *, const char *);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * Flags for the match() function:
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * MATCH_F_STRICT
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * A strict match requires an explicit match to
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * a user specified match (-I, -N, -T) option. A
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * non-strict match also succeeds if the match
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * list is empty.
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * MATCH_F_PHDR
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * The match item is a program header. If this
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * flag is not set, the match item is a section
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * MATCH_F_NAME
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * The name parameter contains valid information.
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * MATCH_F_NDX
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * The ndx argument contains valid information
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * MATCH_F_TYPE
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * The type argument contains valid information
981a172d53aeb81520fcfecf6ab2615277c7bd18abtypedef enum {
981a172d53aeb81520fcfecf6ab2615277c7bd18ab/* It is common for calls to match() to specify all three arguments */
981a172d53aeb81520fcfecf6ab2615277c7bd18ab#define MATCH_F_ALL (MATCH_F_NAME | MATCH_F_NDX | MATCH_F_TYPE)
981a172d53aeb81520fcfecf6ab2615277c7bd18abextern int match(match_flags_t, const char *, uint_t, uint_t);
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab * Possible return values from corenote()
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87abtypedef enum {
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab CORENOTE_R_OK = 0, /* Note data successfully displayed */
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab CORENOTE_R_OK_DUMP = 1, /* Note OK, but not handled. Display Hex dump */
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab CORENOTE_R_BADDATA = 2, /* Note data truncated or otherwise malformed */
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab CORENOTE_R_BADARCH = 3, /* core file note code does not contain */
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab /* support for given architecture */
5aefb6555731130ca4fd295960123d71f2d21fe8rie * Define various elfdump() functions into their 32-bit and 64-bit variants.
5aefb6555731130ca4fd295960123d71f2d21fe8rie#if defined(_ELF64)
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87abextern corenote_ret_t corenote(Half, int, Word, const char *, Word);
37915d862fc5cc87b5b702954d7d7f16a9f98e5cRichard Loweextern void dump_eh_frame(const char *, char *, uchar_t *, size_t, uint64_t,
37915d862fc5cc87b5b702954d7d7f16a9f98e5cRichard Lowe Half e_machine, uchar_t *e_ident, uint64_t gotaddr);
7e16fca05dfbcfd32c2ebc9e4d1abdac1cd8657cAli Bahramiextern void dump_hex_bytes(const void *, size_t, int, int, int);
39773e466ff90ce703d7f52f3267d7e96c09c6f5abextern int fake_shdr_cache32(const char *, int, Elf *, Elf32_Ehdr *,
39773e466ff90ce703d7f52f3267d7e96c09c6f5abextern int fake_shdr_cache64(const char *, int, Elf *, Elf64_Ehdr *,
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahramiextern int regular32(const char *, int, Elf *, uint_t, const char *, int,
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahramiextern int regular64(const char *, int, Elf *, uint_t, const char *, int,
5aefb6555731130ca4fd295960123d71f2d21fe8rie#endif /* __ELFDUMP_H */