dump.c revision d579eb63ae5b8d8c65917b341e8c19a4df710606
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * CDDL HEADER START
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * The contents of this file are subject to the terms of the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Common Development and Distribution License (the "License").
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * You may not use this file except in compliance with the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * or http://www.opensolaris.org/os/licensing.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * See the License for the specific language governing permissions
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * and limitations under the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * When distributing Covered Code, include this CDDL HEADER in each
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * If applicable, add the following below this CDDL HEADER, with the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * fields enclosed by brackets "[]" replaced with your own identifying
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * information: Portions Copyright [yyyy] [name of copyright owner]
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * CDDL HEADER END
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Copyright (c) 1988 AT&T
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * All Rights Reserved
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Use is subject to license terms.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#pragma ident "%Z%%M% %I% %E% SMI"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy/* Get definitions for the relocation types supported. */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#define OPTSTR "agcd:fhn:oprstvCLT:V?" /* option string for getopt() */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * DUMP_CONVFMT defines the libconv formatting options we want to use:
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * - Unknown items to be printed as integers using decimal formatting
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * - The "Dump Style" versions of strings.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#define DUMP_CONVFMT (CONV_FMT_DECIMAL|CONV_FMT_ALTDUMP)
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic SCNTAB *p_symtab, *p_head_scns, *p_dynsym;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy x_flag = 0, /* option requires section header table */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy z_flag = 0, /* process files within an archive */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy rn_flag = 0; /* dump named relocation information */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy /* flags: ?_flag corresponds to ? option */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy a_flag = 0, /* dump archive header of each member of archive */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy g_flag = 0, /* dump archive symbol table */
d_hi = 0,
d_num = 0;
T_hi = 0,
T_num = 0;
char *prog_name;
static int errflag = 0;
static struct stab_list_s {
char *strings;
} *StringTableList = (void *)0;
extern void ar_sym_read();
extern void dump_exec_header();
p_data = 0;
return (NULL);
p_data = 0;
return (NULL);
usage()
if (errflag) {
char *lasts;
if (!(*low))
if (!(*high))
prog_name, w);
s = NULL;
unsigned char *strtab;
unsigned long *temp;
section_size = 0;
if ((strtab = (unsigned char *)
while (section_size != 0) {
* to a table lookup in dumpmap.h.
size_t j;
count = 0;
static int n_title = 0;
int ndx = 0;
char *sym_name;
int adj = 0;
if ((rel_entsize == 0) ||
while (no_entries--) {
ndx++;
ndx++;
if (!n_title) {
if (d_flag) {
if (!d_hi)
ndx++;
if (!v_flag) {
(int)len);
ndx++;
static int n_title = 0;
int ndx = 0;
char *sym_name;
int adj = 0;
if ((rel_entsize == 0) ||
while (no_entries--) {
ndx++;
ndx++;
if (!n_title) {
if (d_flag) {
if (!d_hi)
ndx++;
if (!v_flag) {
ndx++;
demangled_name(char *s)
char *dn;
return (buf);
unsigned int nosymshndx = 0;
while (range > 0) {
char *sym_name = (char *)0;
int specsec;
unsigned int shndx;
_scn = 0;
nosymshndx = 0;
specsec = 0;
specsec = 0;
if (!v_flag) {
DUMP_CONVFMT));
if (specsec) {
if (C_flag)
range--;
SCNTAB *p;
int num;
int field;
if (!v_flag) {
if (hi)
int r_title = 0;
int adj = 0;
while (num_scns-- > 0) {
p_scns++;
sym_size = 0;
reloc_size = 0;
if (n_flag) {
if (d_flag) {
rn_flag = 0;
== NULL) {
if (n_flag) {
if (d_flag) {
rn_flag = 0;
p_scns++;
unsigned char *strtab;
int beg_of_string;
int counter = 0;
int str_off;
if (!p_flag) {
for (i = 0; i < num_scns; i++, s++) {
str_off = 0;
if (!p_flag) {
section_size = 0;
if ((strtab = (unsigned char *)
if (section_size != 0) {
beg_of_string = 0;
while (section_size--) {
unsigned char c = *strtab++;
if (beg_of_string) {
counter++;
beg_of_string = 0;
str_off++;
(void) putchar(c);
int found_it = 0;
sym_size = 0;
if ((sym_data =
if (!p_flag) {
(void) printf(
(void) printf(
if (!found_it) {
} else if (T_flag) {
if (T_num < 0)
if (!p_flag) {
(void) printf(
(void) printf(
if (!p_flag) {
(void) printf(
(void) printf(
int header_num = 0;
const char *str;
if (!p_flag)
int ii;
if (!p_flag) {
ii = 0;
DUMP_CONVFMT));
case DT_PLTGOT:
case DT_HASH:
case DT_STRTAB:
case DT_RELA:
case DT_SYMTAB:
case DT_INIT:
case DT_FINI:
case DT_REL:
case DT_DEBUG:
case DT_TEXTREL:
case DT_JMPREL:
case DT_INIT_ARRAY:
case DT_FINI_ARRAY:
case DT_INIT_ARRAYSZ:
case DT_FINI_ARRAYSZ:
case DT_PREINIT_ARRAY:
case DT_PREINIT_ARRAYSZ:
case DT_SUNW_RTLDINF:
case DT_SUNW_CAP:
case DT_SUNW_SYMTAB:
case DT_SUNW_SYMSORT:
case DT_SUNW_TLSSORT:
case DT_PLTPAD:
case DT_MOVETAB:
case DT_SYMINFO:
case DT_RELACOUNT:
case DT_RELCOUNT:
case DT_VERSYM:
case DT_VERDEF:
case DT_VERDEFNUM:
case DT_VERNEED:
case DT_NEEDED:
case DT_SONAME:
case DT_RPATH:
case DT_RUNPATH:
case DT_SUNW_AUXILIARY:
case DT_SUNW_FILTER:
case DT_CONFIG:
case DT_DEPAUDIT:
case DT_AUDIT:
case DT_AUXILIARY:
case DT_USED:
case DT_FILTER:
case DT_PLTRELSZ:
case DT_RELASZ:
case DT_RELAENT:
case DT_STRSZ:
case DT_SYMENT:
case DT_RELSZ:
case DT_RELENT:
case DT_PLTREL:
case DT_BIND_NOW:
case DT_CHECKSUM:
case DT_PLTPADSZ:
case DT_MOVEENT:
case DT_MOVESZ:
case DT_SYMINSZ:
case DT_SYMINENT:
case DT_VERNEEDNUM:
case DT_SPARC_REGISTER:
case DT_SUNW_SYMSZ:
case DT_SUNW_SORTENT:
case DT_SUNW_SYMSORTSZ:
case DT_SUNW_TLSSORTSZ:
case DT_FLAGS:
case DT_FEATURE_1:
case DT_POSFLAG_1:
case DT_FLAGS_1:
if (v_flag) {
case DT_FLAGS:
case DT_FEATURE_1:
case DT_POSFLAG_1:
case DT_FLAGS_1:
case DT_SYMBOLIC:
while (--lib_scns > 0) {
l_scns++;
header_num++;
static GElf_Ehdr *
int class;
int field;
return (NULL);
if (!f_flag)
return (elf_head_p);
if (!p_flag) {
if (!v_flag) {
int field;
if (!p_flag) {
(void) printf(
return (NULL);
return (NULL);
return (elf_head_p);
unsigned char *p_sec;
for (i = 0; i < num_scns; i++, p++) {
size = 0;
if (n_flag) {
n_range = s;
if (!found_it) {
if (d_flag) {
d_range = s;
if (d_num < 0)
int field;
if (!p_flag) {
if (n_flag) {
n_range = s;
if (!found_it) {
if (d_flag) {
d_range = s;
if (d_num < 0)
int found = 0;
unsigned int num_scns;
buffer++;
if (h_flag) {
if (c_flag) {
if (r_flag) {
if (L_flag) {
if (s_flag) {
static struct stab_list_s *
if (p_ar) {
if (!STabList)
return (STabList);
int title = 0;
int err = 0;
if (g_flag)
filename);
if (a_flag) {
if (!v_flag)
(void) printf(
(void) printf(
if (!v_flag) {
(void) printf(
(void) printf(
buf,
if (err != 0) {
char *fullname;
if (o_flag)
if (x_flag)
int fd;
errno = 0;
filename);
if (z_flag)
if (o_flag)
filename);
if (x_flag)
int optchar;
switch (optchar) {
n_flag++;
(const char *)SGU_PKG,
(const char *)SGU_REL);
usage();
optind++;