1998-06-11 21:51:56 +00:00
|
|
|
|
/* readelf.c -- display contents of an ELF format file
|
|
|
|
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
Originally developed by Eric Youngdale <eric@andante.jic.com>
|
|
|
|
|
Modifications by Nick Clifton <nickc@cygnus.com>
|
|
|
|
|
|
|
|
|
|
This file is part of GNU Binutils.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
|
02111-1307, USA. */
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <sys/stat.h>
|
1998-06-23 18:12:44 +00:00
|
|
|
|
#include <stdio.h>
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
#include "bfd.h"
|
|
|
|
|
#include "elf/common.h"
|
|
|
|
|
#include "elf/ppc.h"
|
|
|
|
|
#include "elf/m32r.h"
|
|
|
|
|
#include "elf/mips.h"
|
|
|
|
|
#include "elf/external.h"
|
|
|
|
|
#include "elf/internal.h"
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
#include "bucomm.h"
|
1998-06-12 00:56:39 +00:00
|
|
|
|
#include "getopt.h"
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
#ifdef ANSI_PROTOTYPES
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <varargs.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
char * program_name = "readelf";
|
|
|
|
|
unsigned int dynamic_addr;
|
|
|
|
|
unsigned int dynamic_size;
|
|
|
|
|
unsigned int rela_addr;
|
|
|
|
|
unsigned int rela_size;
|
|
|
|
|
char * dynamic_strings;
|
|
|
|
|
char * string_table;
|
|
|
|
|
Elf_Internal_Sym * dynamic_symbols;
|
|
|
|
|
char program_interpreter [64];
|
|
|
|
|
int dynamic_info [DT_JMPREL + 1];
|
|
|
|
|
int version_info [16];
|
|
|
|
|
int loadaddr = 0;
|
|
|
|
|
Elf_Internal_Ehdr elf_header;
|
|
|
|
|
Elf_Internal_Shdr * section_headers;
|
|
|
|
|
int show_name;
|
|
|
|
|
int do_dynamic;
|
|
|
|
|
int do_syms;
|
|
|
|
|
int do_reloc;
|
|
|
|
|
int do_sections;
|
|
|
|
|
int do_segments;
|
|
|
|
|
int do_using_dynamic;
|
|
|
|
|
int do_header;
|
|
|
|
|
int do_dump;
|
|
|
|
|
int do_version;
|
|
|
|
|
|
1998-07-08 03:55:07 +00:00
|
|
|
|
static unsigned long int (* byte_get) PARAMS ((unsigned char *, int));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
#define NUM_DUMP_SECTS 100
|
1998-06-30 00:03:05 +00:00
|
|
|
|
char dump_sects [NUM_DUMP_SECTS];
|
|
|
|
|
|
1998-06-11 21:51:56 +00:00
|
|
|
|
#define HEX_DUMP 1
|
|
|
|
|
#define DISASS_DUMP 2
|
|
|
|
|
|
|
|
|
|
/* Forward declarations for dumb compilers. */
|
1998-06-23 18:12:44 +00:00
|
|
|
|
static char * get_dynamic_type PARAMS ((unsigned long));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static char * get_i386_rel_type PARAMS ((unsigned long rtype));
|
|
|
|
|
static char * get_m68k_rel_type PARAMS ((unsigned long rtype));
|
|
|
|
|
static char * get_sparc_rel_type PARAMS ((unsigned long rtype));
|
|
|
|
|
static char * get_m32r_rel_type PARAMS ((unsigned long rtype));
|
|
|
|
|
static char * get_v850_rel_type PARAMS ((unsigned long rtype));
|
|
|
|
|
static char * get_d10v_rel_type PARAMS ((unsigned long rtype));
|
1998-06-13 15:15:13 +00:00
|
|
|
|
/* start-sanitize-d30v */
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static char * get_d30v_rel_type PARAMS ((unsigned long rtype));
|
1998-06-13 15:15:13 +00:00
|
|
|
|
/* end-sanitize-d30v */
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static char * get_sh_rel_type PARAMS ((unsigned long rtype));
|
|
|
|
|
static char * get_mn10300_rel_type PARAMS ((unsigned long rtype));
|
|
|
|
|
static char * get_mn10200_rel_type PARAMS ((unsigned long rtype));
|
|
|
|
|
static char * get_ppc_rel_type PARAMS ((unsigned long rtype));
|
|
|
|
|
static int dump_relocations
|
|
|
|
|
PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Sym *, char *));
|
1998-06-23 18:12:44 +00:00
|
|
|
|
static char * get_file_type PARAMS ((unsigned e_type));
|
|
|
|
|
static char * get_machine_name PARAMS ((unsigned e_machine));
|
|
|
|
|
static char * get_machine_data PARAMS ((unsigned e_data));
|
|
|
|
|
static char * get_machine_flags PARAMS ((unsigned, unsigned e_machine));
|
|
|
|
|
static char * get_segment_type PARAMS ((unsigned long p_type));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
static char * get_section_type_name PARAMS ((unsigned int sh_type));
|
1998-06-23 18:12:44 +00:00
|
|
|
|
static char * get_symbol_binding PARAMS ((unsigned int binding));
|
|
|
|
|
static char * get_symbol_type PARAMS ((unsigned int type));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
static void usage PARAMS ((void));
|
|
|
|
|
static void parse_args PARAMS ((int argc, char ** argv));
|
1998-06-23 18:12:44 +00:00
|
|
|
|
static int process_file_header PARAMS ((void));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int process_program_headers PARAMS ((FILE *));
|
|
|
|
|
static int process_section_headers PARAMS ((FILE *));
|
|
|
|
|
static int process_dynamic_segment PARAMS ((FILE *));
|
|
|
|
|
static int process_symbol_table PARAMS ((FILE *));
|
|
|
|
|
static int process_section_contents PARAMS ((FILE *));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
static void process_file PARAMS ((char * file_name));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int process_relocs PARAMS ((FILE *));
|
|
|
|
|
static int process_version_sections PARAMS ((FILE *));
|
1998-06-23 18:12:44 +00:00
|
|
|
|
static char * get_ver_flags PARAMS ((unsigned short flags));
|
|
|
|
|
static char * get_symbol_index_type PARAMS ((unsigned short type));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int get_section_headers PARAMS ((FILE * file));
|
|
|
|
|
static int get_file_header PARAMS ((FILE * file));
|
|
|
|
|
static Elf_Internal_Sym * get_elf_symbols
|
|
|
|
|
PARAMS ((FILE * file, unsigned long offset, unsigned long number));
|
|
|
|
|
static int * get_dynamic_data PARAMS ((FILE * file, unsigned int number));
|
|
|
|
|
|
|
|
|
|
#define SECTION_NAME(X) (string_table + (X)->sh_name)
|
|
|
|
|
|
|
|
|
|
#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
|
|
|
|
|
|
|
|
|
|
#define BYTE_GET(field) byte_get (field, sizeof (field))
|
|
|
|
|
|
|
|
|
|
#define NUM_ELEM(array) (sizeof (array) / sizeof ((array)[0]))
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
#define GET_DATA_ALLOC(offset, size, var, type, reason) \
|
|
|
|
|
if (fseek (file, offset, SEEK_SET)) \
|
|
|
|
|
{ \
|
|
|
|
|
error (_("Unable to seek to start of %s at %x\n"), reason, offset); \
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 0; \
|
1998-06-23 18:12:44 +00:00
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
var = (type) malloc (size); \
|
|
|
|
|
\
|
|
|
|
|
if (var == NULL) \
|
|
|
|
|
{ \
|
|
|
|
|
error (_("Out of memory allocating %d bytes for %s\n"), size, reason); \
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 0; \
|
1998-06-23 18:12:44 +00:00
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
if (fread (var, size, 1, file) != 1) \
|
|
|
|
|
{ \
|
|
|
|
|
error (_("Unable to read in %d bytes of %s\n"), size, reason); \
|
|
|
|
|
free (var); \
|
|
|
|
|
var = NULL; \
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 0; \
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define GET_DATA(offset, var, reason) \
|
|
|
|
|
if (fseek (file, offset, SEEK_SET)) \
|
|
|
|
|
{ \
|
|
|
|
|
error (_("Unable to seek to %x for %s\n"), offset, reason); \
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 0; \
|
1998-06-23 18:12:44 +00:00
|
|
|
|
} \
|
|
|
|
|
else if (fread (& var, sizeof (var), 1, file) != 1) \
|
|
|
|
|
{ \
|
|
|
|
|
error (_("Unable to read data at %x for %s\n"), offset, reason); \
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 0; \
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
#ifdef ANSI_PROTOTYPES
|
|
|
|
|
static void
|
|
|
|
|
error (const char * message, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
fprintf (stderr, _("%s: Error: "), program_name);
|
|
|
|
|
va_start (args, message);
|
|
|
|
|
vfprintf (stderr, message, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
warn (const char * message, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
fprintf (stderr, _("%s: Warning: "), program_name);
|
|
|
|
|
va_start (args, message);
|
|
|
|
|
vfprintf (stderr, message, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
static void
|
|
|
|
|
error (va_alist)
|
1998-07-08 03:55:07 +00:00
|
|
|
|
va_dcl
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
char * message;
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
fprintf (stderr, _("%s: Error: "), program_name);
|
|
|
|
|
va_start (args);
|
|
|
|
|
message = va_arg (args, char *);
|
|
|
|
|
vfprintf (stderr, message, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
warn (va_alist)
|
1998-07-08 03:55:07 +00:00
|
|
|
|
va_dcl
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
char * message;
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
fprintf (stderr, _("%s: Warning: "), program_name);
|
|
|
|
|
va_start (args);
|
|
|
|
|
message = va_arg (args, char *);
|
|
|
|
|
vfprintf (stderr, message, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static unsigned long int
|
|
|
|
|
byte_get_little_endian (field, size)
|
|
|
|
|
unsigned char * field;
|
|
|
|
|
int size;
|
|
|
|
|
{
|
|
|
|
|
switch (size)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
return * field;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
return ((unsigned int) (field [0]))
|
|
|
|
|
| (((unsigned int) (field [1])) << 8);
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
return ((unsigned long) (field [0]))
|
|
|
|
|
| (((unsigned long) (field [1])) << 8)
|
|
|
|
|
| (((unsigned long) (field [2])) << 16)
|
|
|
|
|
| (((unsigned long) (field [3])) << 24);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
error (_("Unhandled data length: %d\n"), size);
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned long int
|
|
|
|
|
byte_get_big_endian (field, size)
|
|
|
|
|
unsigned char * field;
|
|
|
|
|
int size;
|
|
|
|
|
{
|
|
|
|
|
switch (size)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
return * field;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
return ((unsigned int) (field [1])) | (((int) (field [0])) << 8);
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
return ((unsigned long) (field [3]))
|
|
|
|
|
| (((unsigned long) (field [2])) << 8)
|
|
|
|
|
| (((unsigned long) (field [1])) << 16)
|
|
|
|
|
| (((unsigned long) (field [0])) << 24);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
error (_("Unhandled data length: %d\n"), size);
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_i386_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_386_NONE";
|
|
|
|
|
case 1: return "R_386_32";
|
|
|
|
|
case 2: return "R_386_PC32";
|
|
|
|
|
case 3: return "R_386_GOT32";
|
|
|
|
|
case 4: return "R_386_PLT32";
|
|
|
|
|
case 5: return "R_386_COPY";
|
|
|
|
|
case 6: return "R_386_GLOB_DAT";
|
|
|
|
|
case 7: return "R_386_JMP_SLOT";
|
|
|
|
|
case 8: return "R_386_RELATIVE";
|
|
|
|
|
case 9: return "R_386_GOTOFF";
|
|
|
|
|
case 10: return "R_386_GOTPC";
|
|
|
|
|
case 20: return "R_386_16";
|
|
|
|
|
case 21: return "R_386_PC16";
|
|
|
|
|
case 22: return "R_386_PC8";
|
|
|
|
|
case 23: return "R_386_max";
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_m68k_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_68K_NONE";
|
|
|
|
|
case 1: return "R_68K_32";
|
|
|
|
|
case 2: return "R_68K_16";
|
|
|
|
|
case 3: return "R_68K_8";
|
|
|
|
|
case 4: return "R_68K_PC32";
|
|
|
|
|
case 5: return "R_68K_PC16";
|
|
|
|
|
case 6: return "R_68K_PC8";
|
|
|
|
|
case 7: return "R_68K_GOT32";
|
|
|
|
|
case 8: return "R_68K_GOT16";
|
|
|
|
|
case 9: return "R_68K_GOT8";
|
|
|
|
|
case 10: return "R_68K_GOT32O";
|
|
|
|
|
case 11: return "R_68K_GOT16O";
|
|
|
|
|
case 12: return "R_68K_GOT8O";
|
|
|
|
|
case 13: return "R_68K_PLT32";
|
|
|
|
|
case 14: return "R_68K_PLT16";
|
|
|
|
|
case 15: return "R_68K_PLT8";
|
|
|
|
|
case 16: return "R_68K_PLT32O";
|
|
|
|
|
case 17: return "R_68K_PLT16O";
|
|
|
|
|
case 18: return "R_68K_PLT8O";
|
|
|
|
|
case 19: return "R_68K_COPY";
|
|
|
|
|
case 20: return "R_68K_GLOB_DAT";
|
|
|
|
|
case 21: return "R_68K_JMP_SLOT";
|
|
|
|
|
case 22: return "R_68K_RELATIVE";
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_sparc_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_SPARC_NONE";
|
|
|
|
|
case 1: return "R_SPARC_8";
|
|
|
|
|
case 2: return "R_SPARC_16";
|
|
|
|
|
case 3: return "R_SPARC_32";
|
|
|
|
|
case 4: return "R_SPARC_DISP8";
|
|
|
|
|
case 5: return "R_SPARC_DISP16";
|
|
|
|
|
case 6: return "R_SPARC_DISP32";
|
|
|
|
|
case 7: return "R_SPARC_WDISP30";
|
|
|
|
|
case 8: return "R_SPARC_WDISP22";
|
|
|
|
|
case 9: return "R_SPARC_HI22";
|
|
|
|
|
case 10: return "R_SPARC_22";
|
|
|
|
|
case 11: return "R_SPARC_13";
|
|
|
|
|
case 12: return "R_SPARC_LO10";
|
|
|
|
|
case 13: return "R_SPARC_GOT10";
|
|
|
|
|
case 14: return "R_SPARC_GOT13";
|
|
|
|
|
case 15: return "R_SPARC_GOT22";
|
|
|
|
|
case 16: return "R_SPARC_PC10";
|
|
|
|
|
case 17: return "R_SPARC_PC22";
|
|
|
|
|
case 18: return "R_SPARC_WPLT30";
|
|
|
|
|
case 19: return "R_SPARC_COPY";
|
|
|
|
|
case 20: return "R_SPARC_GLOB_DAT";
|
|
|
|
|
case 21: return "R_SPARC_JMP_SLOT";
|
|
|
|
|
case 22: return "R_SPARC_RELATIVE";
|
|
|
|
|
case 23: return "R_SPARC_UA32";
|
|
|
|
|
case 24: return "R_SPARC_10";
|
|
|
|
|
case 25: return "R_SPARC_11";
|
|
|
|
|
case 26: return "R_SPARC_64";
|
|
|
|
|
case 27: return "R_SPARC_OLO10";
|
|
|
|
|
case 28: return "R_SPARC_HH22";
|
|
|
|
|
case 29: return "R_SPARC_HM10";
|
|
|
|
|
case 30: return "R_SPARC_LM22";
|
|
|
|
|
case 31: return "R_SPARC_PC_HH22";
|
|
|
|
|
case 32: return "R_SPARC_PC_HM10";
|
|
|
|
|
case 33: return "R_SPARC_PC_LM22";
|
|
|
|
|
case 34: return "R_SPARC_WDISP16";
|
|
|
|
|
case 35: return "R_SPARC_WDISP19";
|
|
|
|
|
case 36: return "R_SPARC_UNUSED_42";
|
|
|
|
|
case 37: return "R_SPARC_7";
|
|
|
|
|
case 38: return "R_SPARC_5";
|
|
|
|
|
case 39: return "R_SPARC_6";
|
|
|
|
|
case 40: return "R_SPARC_DISP64";
|
|
|
|
|
case 41: return "R_SPARC_PLT64";
|
|
|
|
|
case 42: return "R_SPARC_HIX22";
|
|
|
|
|
case 43: return "R_SPARC_LOX10";
|
|
|
|
|
case 44: return "R_SPARC_H44";
|
|
|
|
|
case 45: return "R_SPARC_M44";
|
|
|
|
|
case 46: return "R_SPARC_L44";
|
|
|
|
|
case 47: return "R_SPARC_REGISTER";
|
|
|
|
|
case 48: return "R_SPARC_UA64";
|
|
|
|
|
case 49: return "R_SPARC_UA16";
|
|
|
|
|
case 50: return "R_SPARC_32LE";
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_m32r_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_M32R_NONE";
|
|
|
|
|
case 1: return "R_M32R_16";
|
|
|
|
|
case 2: return "R_M32R_32";
|
|
|
|
|
case 3: return "R_M32R_24";
|
|
|
|
|
case 4: return "R_M32R_10_PCREL";
|
|
|
|
|
case 5: return "R_M32R_18_PCREL";
|
|
|
|
|
case 6: return "R_M32R_26_PCREL";
|
|
|
|
|
case 7: return "R_M32R_HI16_ULO";
|
|
|
|
|
case 8: return "R_M32R_HI16_SLO";
|
|
|
|
|
case 9: return "R_M32R_LO16";
|
|
|
|
|
case 10: return "R_M32R_SDA16";
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_v850_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_V850_NONE";
|
|
|
|
|
case 1: return "R_V850_9_PCREL";
|
|
|
|
|
case 2: return "R_V850_22_PCREL";
|
|
|
|
|
case 3: return "R_V850_HI16_S";
|
|
|
|
|
case 4: return "R_V850_HI16";
|
|
|
|
|
case 5: return "R_V850_LO16";
|
|
|
|
|
case 6: return "R_V850_32";
|
|
|
|
|
case 7: return "R_V850_16";
|
|
|
|
|
case 8: return "R_V850_8";
|
|
|
|
|
case 9: return "R_V850_SDA_16_16_OFFSET";
|
|
|
|
|
case 10: return "R_V850_SDA_15_16_OFFSET";
|
|
|
|
|
case 11: return "R_V850_ZDA_16_16_OFFSET";
|
|
|
|
|
case 12: return "R_V850_ZDA_15_16_OFFSET";
|
|
|
|
|
case 13: return "R_V850_TDA_6_8_OFFSET";
|
|
|
|
|
case 14: return "R_V850_TDA_7_8_OFFSET";
|
|
|
|
|
case 15: return "R_V850_TDA_7_7_OFFSET";
|
|
|
|
|
case 16: return "R_V850_TDA_16_16_OFFSET";
|
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
case 17: return "R_V850_TDA_4_5_OFFSET";
|
|
|
|
|
case 18: return "R_V850_TDA_4_4_OFFSET";
|
|
|
|
|
case 19: return "R_V850_SDA_16_16_SPLIT_OFFSET";
|
|
|
|
|
case 20: return "R_V850_ZDA_16_16_SPLIT_OFFSET";
|
|
|
|
|
case 21: return "R_V850_CALLT_6_7_OFFSET";
|
|
|
|
|
case 22: return "R_V850_CALLT_16_16_OFFSET";
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_d10v_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_D10V_NONE";
|
|
|
|
|
case 1: return "R_D10V_10_PCREL_R";
|
|
|
|
|
case 2: return "R_D10V_10_PCREL_L";
|
|
|
|
|
case 3: return "R_D10V_16";
|
|
|
|
|
case 4: return "R_D10V_18";
|
|
|
|
|
case 5: return "R_D10V_18_PCREL";
|
|
|
|
|
case 6: return "R_D10V_32";
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-13 15:15:13 +00:00
|
|
|
|
/* start-sanitize-d30v */
|
1998-06-11 21:51:56 +00:00
|
|
|
|
static char *
|
|
|
|
|
get_d30v_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_D30V_NONE";
|
|
|
|
|
case 1: return "R_D30V_6";
|
|
|
|
|
case 2: return "R_D30V_9_PCREL";
|
|
|
|
|
case 3: return "R_D30V_9_PCREL_R";
|
|
|
|
|
case 4: return "R_D30V_15";
|
|
|
|
|
case 5: return "R_D30V_15_PCREL";
|
|
|
|
|
case 6: return "R_D30V_15_PCREL_R";
|
|
|
|
|
case 7: return "R_D30V_21";
|
|
|
|
|
case 8: return "R_D30V_21_PCREL";
|
|
|
|
|
case 9: return "R_D30V_21_PCREL_R";
|
|
|
|
|
case 10: return "R_D30V_32";
|
|
|
|
|
case 11: return "R_D30V_32_PCREL";
|
|
|
|
|
case 12: return "R_D30V_32_NORMAL";
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-13 15:15:13 +00:00
|
|
|
|
/* end-sanitize-d30v */
|
1998-06-11 21:51:56 +00:00
|
|
|
|
static char *
|
|
|
|
|
get_sh_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_SH_NONE";
|
|
|
|
|
case 1: return "R_SH_DIR32";
|
|
|
|
|
case 2: return "R_SH_REL32";
|
|
|
|
|
case 3: return "R_SH_DIR8WPN";
|
|
|
|
|
case 4: return "R_SH_IND12W";
|
|
|
|
|
case 5: return "R_SH_DIR8WPL";
|
|
|
|
|
case 6: return "R_SH_DIR8WPZ";
|
|
|
|
|
case 7: return "R_SH_DIR8BP";
|
|
|
|
|
case 8: return "R_SH_DIR8W";
|
|
|
|
|
case 9: return "R_SH_DIR8L";
|
|
|
|
|
case 25: return "R_SH_SWITCH16";
|
|
|
|
|
case 26: return "R_SH_SWITCH32";
|
|
|
|
|
case 27: return "R_SH_USES";
|
|
|
|
|
case 28: return "R_SH_COUNT";
|
|
|
|
|
case 29: return "R_SH_ALIGN";
|
|
|
|
|
case 30: return "R_SH_CODE";
|
|
|
|
|
case 31: return "R_SH_DATA";
|
|
|
|
|
case 32: return "R_SH_LABEL";
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_mn10300_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_MN10300_NONE";
|
|
|
|
|
case 1: return "R_MN10300_32";
|
|
|
|
|
case 2: return "R_MN10300_16";
|
|
|
|
|
case 3: return "R_MN10300_8";
|
|
|
|
|
case 4: return "R_MN10300_PCREL32";
|
|
|
|
|
case 5: return "R_MN10300_PCREL16";
|
|
|
|
|
case 6: return "R_MN10300_PCREL8";
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_mn10200_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_MN10200_NONE";
|
|
|
|
|
case 1: return "R_MN10200_32";
|
|
|
|
|
case 2: return "R_MN10200_16";
|
|
|
|
|
case 3: return "R_MN10200_8";
|
|
|
|
|
case 4: return "R_MN10200_24";
|
|
|
|
|
case 5: return "R_MN10200_PCREL8";
|
|
|
|
|
case 6: return "R_MN10200_PCREL16";
|
|
|
|
|
case 7: return "R_MN10200_PCREL24";
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1998-06-12 20:50:03 +00:00
|
|
|
|
static char *
|
|
|
|
|
get_ppc_rel_type (rtype)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long rtype;
|
1998-06-12 20:50:03 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rtype)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "R_PPC_NONE,";
|
|
|
|
|
case 1: return "R_PPC_ADDR32,";
|
|
|
|
|
case 2: return "R_PPC_ADDR24,";
|
|
|
|
|
case 3: return "R_PPC_ADDR16,";
|
|
|
|
|
case 4: return "R_PPC_ADDR16_LO,";
|
|
|
|
|
case 5: return "R_PPC_ADDR16_HI,";
|
|
|
|
|
case 6: return "R_PPC_ADDR16_HA,";
|
|
|
|
|
case 7: return "R_PPC_ADDR14,";
|
|
|
|
|
case 8: return "R_PPC_ADDR14_BRTAKEN,";
|
|
|
|
|
case 9: return "R_PPC_ADDR14_BRNTAKEN,";
|
|
|
|
|
case 10: return "R_PPC_REL24,";
|
|
|
|
|
case 11: return "R_PPC_REL14,";
|
|
|
|
|
case 12: return "R_PPC_REL14_BRTAKEN,";
|
|
|
|
|
case 13: return "R_PPC_REL14_BRNTAKEN,";
|
|
|
|
|
case 14: return "R_PPC_GOT16,";
|
|
|
|
|
case 15: return "R_PPC_GOT16_LO,";
|
|
|
|
|
case 16: return "R_PPC_GOT16_HI,";
|
|
|
|
|
case 17: return "R_PPC_GOT16_HA,";
|
|
|
|
|
case 18: return "R_PPC_PLT24,";
|
|
|
|
|
case 19: return "R_PPC_COPY,";
|
|
|
|
|
case 21: return "R_PPC_JMP_SLOT,";
|
|
|
|
|
case 22: return "R_PPC_RELATIVE,";
|
|
|
|
|
case 23: return "R_PPC_LOCAL24PC,";
|
|
|
|
|
case 24: return "R_PPC_UADDR32,";
|
|
|
|
|
case 25: return "R_PPC_UADDR16,";
|
|
|
|
|
case 26: return "R_PPC_REL32,";
|
|
|
|
|
case 27: return "R_PPC_PLT32,";
|
|
|
|
|
case 28: return "R_PPC_PLTREL32,";
|
|
|
|
|
case 29: return "R_PPC_PLT16_LO,";
|
|
|
|
|
case 30: return "R_PPC_PLT16_HI,";
|
|
|
|
|
case 31: return "R_PPC_PLT16_HA,";
|
|
|
|
|
case 32: return "R_PPC_SDAREL,";
|
|
|
|
|
case 33: return "R_PPC_SECTOFF,";
|
|
|
|
|
case 34: return "R_PPC_SECTOFF_LO,";
|
|
|
|
|
case 35: return "R_PPC_SECTOFF_HI,";
|
|
|
|
|
case 36: return "R_PPC_SECTOFF_HA,";
|
|
|
|
|
case 101: return "R_PPC_EMB_NADDR32,";
|
|
|
|
|
case 102: return "R_PPC_EMB_NADDR16,";
|
|
|
|
|
case 103: return "R_PPC_EMB_NADDR16_LO,";
|
|
|
|
|
case 104: return "R_PPC_EMB_NADDR16_HI,";
|
|
|
|
|
case 105: return "R_PPC_EMB_NADDR16_HA,";
|
|
|
|
|
case 106: return "R_PPC_EMB_SDAI16,";
|
|
|
|
|
case 107: return "R_PPC_EMB_SDA2I16,";
|
|
|
|
|
case 108: return "R_PPC_EMB_SDA2REL,";
|
|
|
|
|
case 109: return "R_PPC_EMB_SDA21,";
|
|
|
|
|
case 110: return "R_PPC_EMB_MRKREF,";
|
|
|
|
|
case 111: return "R_PPC_EMB_RELSEC16,";
|
|
|
|
|
case 112: return "R_PPC_EMB_RELST_LO,";
|
|
|
|
|
case 113: return "R_PPC_EMB_RELST_HI,";
|
|
|
|
|
case 114: return "R_PPC_EMB_RELST_HA,";
|
|
|
|
|
case 115: return "R_PPC_EMB_BIT_FLD,";
|
|
|
|
|
case 116: return "R_PPC_EMB_RELSDA,";
|
|
|
|
|
default: return _("*INVALID*");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
/* Display the contents of the relocation data
|
|
|
|
|
found at the specified offset. */
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int
|
1998-06-23 18:12:44 +00:00
|
|
|
|
dump_relocations (file, rel_offset, rel_size, symtab, strtab)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
FILE * file;
|
|
|
|
|
unsigned long rel_offset;
|
|
|
|
|
unsigned long rel_size;
|
|
|
|
|
Elf_Internal_Sym * symtab;
|
|
|
|
|
char * strtab;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned int i;
|
|
|
|
|
int is_rela;
|
|
|
|
|
Elf_Internal_Rel * rels;
|
|
|
|
|
Elf_Internal_Rela * relas;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
/* Compute number of relocations and read them in. */
|
|
|
|
|
switch (elf_header.e_machine)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
case EM_386:
|
|
|
|
|
case EM_486:
|
|
|
|
|
case EM_CYGNUS_M32R:
|
|
|
|
|
case EM_CYGNUS_D10V:
|
1998-06-30 00:03:05 +00:00
|
|
|
|
{
|
|
|
|
|
Elf32_External_Rel * erels;
|
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (rel_offset, rel_size, erels,
|
|
|
|
|
Elf32_External_Rel *, "relocs");
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
rel_size = rel_size / sizeof (Elf32_External_Rel);
|
|
|
|
|
|
|
|
|
|
rels = (Elf_Internal_Rel *) malloc (rel_size *
|
|
|
|
|
sizeof (Elf_Internal_Rel));
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < rel_size; i++)
|
|
|
|
|
{
|
|
|
|
|
rels[i].r_offset = BYTE_GET (erels[i].r_offset);
|
|
|
|
|
rels[i].r_info = BYTE_GET (erels[i].r_info);
|
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
free (erels);
|
|
|
|
|
|
|
|
|
|
is_rela = 0;
|
|
|
|
|
relas = (Elf_Internal_Rela *) rels;
|
|
|
|
|
}
|
|
|
|
|
break;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
case EM_68K:
|
|
|
|
|
case EM_SPARC:
|
1998-06-12 20:50:03 +00:00
|
|
|
|
case EM_PPC:
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_CYGNUS_V850:
|
1998-06-13 15:15:13 +00:00
|
|
|
|
/* start-sanitize-d30v */
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_CYGNUS_D30V:
|
1998-06-13 15:15:13 +00:00
|
|
|
|
/* end-sanitize-d30v */
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_CYGNUS_MN10200:
|
|
|
|
|
case EM_CYGNUS_MN10300:
|
|
|
|
|
case EM_SH:
|
1998-06-30 00:03:05 +00:00
|
|
|
|
{
|
|
|
|
|
Elf32_External_Rela * erelas;
|
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (rel_offset, rel_size, erelas,
|
|
|
|
|
Elf32_External_Rela *, "relocs");
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
rel_size = rel_size / sizeof (Elf32_External_Rela);
|
|
|
|
|
|
|
|
|
|
relas = (Elf_Internal_Rela *) malloc (rel_size *
|
|
|
|
|
sizeof (Elf_Internal_Rela));
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < rel_size; i++)
|
|
|
|
|
{
|
|
|
|
|
relas[i].r_offset = BYTE_GET (erelas[i].r_offset);
|
|
|
|
|
relas[i].r_info = BYTE_GET (erelas[i].r_info);
|
|
|
|
|
relas[i].r_addend = BYTE_GET (erelas[i].r_addend);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (erelas);
|
|
|
|
|
|
|
|
|
|
is_rela = 1;
|
|
|
|
|
rels = (Elf_Internal_Rel *) relas;
|
|
|
|
|
}
|
|
|
|
|
break;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
warn (_("Don't know about relocations on this machine architecture\n"));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 0;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_rela)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf
|
|
|
|
|
(_(" Offset Value Type Symbol's Value Symbol's Name Addend\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
else
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf
|
|
|
|
|
(_(" Offset Value Type Symbol's Value Symbol's Name\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < rel_size; i++)
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
char * rtype;
|
|
|
|
|
unsigned long offset;
|
|
|
|
|
unsigned long info;
|
|
|
|
|
int symtab_index;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-11 21:51:56 +00:00
|
|
|
|
if (is_rela)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
|
|
|
|
offset = relas [i].r_offset;
|
|
|
|
|
info = relas [i].r_info;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
offset = rels [i].r_offset;
|
|
|
|
|
info = rels [i].r_info;
|
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (" %8.8lx %5.5lx ", offset, info);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
switch (elf_header.e_machine)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-12 00:56:39 +00:00
|
|
|
|
default:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = "<unknown>";
|
1998-06-12 00:56:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_CYGNUS_M32R:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_m32r_rel_type (ELF32_R_TYPE (info));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EM_386:
|
|
|
|
|
case EM_486:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_i386_rel_type (ELF32_R_TYPE (info));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EM_68K:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_m68k_rel_type (ELF32_R_TYPE (info));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EM_SPARC:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_sparc_rel_type (ELF32_R_TYPE (info));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EM_CYGNUS_V850:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_v850_rel_type (ELF32_R_TYPE (info));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EM_CYGNUS_D10V:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_d10v_rel_type (ELF32_R_TYPE (info));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
1998-06-13 15:15:13 +00:00
|
|
|
|
/* start-sanitize-d30v */
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_CYGNUS_D30V:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_d30v_rel_type (ELF32_R_TYPE (info));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
1998-06-13 15:15:13 +00:00
|
|
|
|
/* end-sanitize-d30v */
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_SH:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_sh_rel_type (ELF32_R_TYPE (info));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EM_CYGNUS_MN10300:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_mn10300_rel_type (ELF32_R_TYPE (info));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EM_CYGNUS_MN10200:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_mn10200_rel_type (ELF32_R_TYPE (info));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
1998-06-12 20:50:03 +00:00
|
|
|
|
|
|
|
|
|
case EM_PPC:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rtype = get_ppc_rel_type (ELF32_R_TYPE (info));
|
1998-06-12 20:50:03 +00:00
|
|
|
|
break;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf ("%-21.21s", rtype);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
symtab_index = ELF32_R_SYM (info);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (symtab_index && symtab != NULL)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_Internal_Sym * psym;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-11 21:51:56 +00:00
|
|
|
|
psym = symtab + symtab_index;
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (" %08lx ", (unsigned long) psym->st_value);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-11 21:51:56 +00:00
|
|
|
|
if (psym->st_name == 0)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf ("%-17.17s",
|
|
|
|
|
SECTION_NAME (section_headers + psym->st_shndx));
|
|
|
|
|
else if (strtab == NULL)
|
|
|
|
|
printf (_("<string table index %d>"), psym->st_name);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
else
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf ("%-17.17s", strtab + psym->st_name);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
if (is_rela)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (" + %lx", (unsigned long) relas [i].r_addend);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
putchar ('\n');
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
free (relas);
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_dynamic_type (type)
|
|
|
|
|
unsigned long type;
|
|
|
|
|
{
|
|
|
|
|
static char buff [32];
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case DT_NULL: return _("NULL");
|
|
|
|
|
case DT_NEEDED: return _("NEEDED");
|
|
|
|
|
case DT_PLTRELSZ: return _("PLTRELSZ");
|
|
|
|
|
case DT_PLTGOT: return _("PLTGOT");
|
|
|
|
|
case DT_HASH: return _("HASH");
|
|
|
|
|
case DT_STRTAB: return _("STRTAB");
|
|
|
|
|
case DT_SYMTAB: return _("SYMTAB");
|
|
|
|
|
case DT_RELA: return _("RELA");
|
|
|
|
|
case DT_RELASZ: return _("RELASZ");
|
|
|
|
|
case DT_RELAENT: return _("RELAENT");
|
|
|
|
|
case DT_STRSZ: return _("STRSZ");
|
|
|
|
|
case DT_SYMENT: return _("SYMENT");
|
|
|
|
|
case DT_INIT: return _("INIT");
|
|
|
|
|
case DT_FINI: return _("FINI");
|
|
|
|
|
case DT_SONAME: return _("SONAME");
|
|
|
|
|
case DT_RPATH: return _("RPATH");
|
|
|
|
|
case DT_SYMBOLIC: return _("SYMBOLIC");
|
|
|
|
|
case DT_REL: return _("REL");
|
|
|
|
|
case DT_RELSZ: return _("RELSZ");
|
|
|
|
|
case DT_RELENT: return _("RELENT");
|
|
|
|
|
case DT_PLTREL: return _("PLTREL");
|
|
|
|
|
case DT_DEBUG: return _("DEBUG");
|
|
|
|
|
case DT_TEXTREL: return _("TEXTREL");
|
|
|
|
|
case DT_JMPREL: return _("JMPREL");
|
|
|
|
|
case DT_VERDEF: return _("VERDEF");
|
|
|
|
|
case DT_VERDEFNUM: return _("VERDEFNUM");
|
|
|
|
|
case DT_VERNEED: return _("VERNEED");
|
|
|
|
|
case DT_VERNEEDNUM: return _("VERNEEDNUM");
|
|
|
|
|
case DT_VERSYM: return _("VERSYN");
|
|
|
|
|
case DT_AUXILIARY: return _("AUXILARY");
|
|
|
|
|
case DT_FILTER: return _("FILTER");
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if ((type >= DT_LOPROC) && (type <= DT_HIPROC))
|
|
|
|
|
sprintf (buff, _("Processor Specific: (%x)"), type);
|
|
|
|
|
else
|
|
|
|
|
sprintf (buff, _("<unknown>: %x"), type);
|
|
|
|
|
return buff;
|
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_file_type (e_type)
|
1998-06-12 20:50:03 +00:00
|
|
|
|
unsigned e_type;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
static char buff [32];
|
|
|
|
|
|
|
|
|
|
switch (e_type)
|
|
|
|
|
{
|
|
|
|
|
case ET_NONE: return _("None");
|
|
|
|
|
case ET_REL: return _("Relocatable file");
|
|
|
|
|
case ET_EXEC: return _("Executable file");
|
|
|
|
|
case ET_DYN: return _("Shared object file");
|
|
|
|
|
case ET_CORE: return _("Core file");
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if ((e_type >= ET_LOPROC) && (e_type <= ET_HIPROC))
|
|
|
|
|
sprintf (buff, _("Processor Specific: (%x)"), e_type);
|
|
|
|
|
else
|
|
|
|
|
sprintf (buff, _("<unknown>: %x"), e_type);
|
|
|
|
|
return buff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_machine_name (e_machine)
|
1998-06-12 20:50:03 +00:00
|
|
|
|
unsigned e_machine;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
static char buff [32];
|
|
|
|
|
|
|
|
|
|
switch (e_machine)
|
|
|
|
|
{
|
|
|
|
|
case EM_NONE: return _("None");
|
|
|
|
|
case EM_M32: return "WE32100";
|
|
|
|
|
case EM_SPARC: return "Sparc";
|
|
|
|
|
case EM_386: return "80386";
|
|
|
|
|
case EM_68K: return "MC68000";
|
|
|
|
|
case EM_88K: return "MC88000";
|
|
|
|
|
case EM_486: return "Intel 80486";
|
|
|
|
|
case EM_860: return "Intel 80860";
|
|
|
|
|
case EM_MIPS: return "MIPS R3000 big-endian";
|
|
|
|
|
case EM_S370: return "Amdahl";
|
|
|
|
|
case EM_MIPS_RS4_BE: return "MIPS R400 big-endian";
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case EM_OLD_SPARCV9: return "Sparc v9 (old)";
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_PARISC: return "HPPA";
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case EM_PPC_OLD: return "Power PC (old)";
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_SPARC32PLUS: return "Sparc v8+" ;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case EM_960: return "Intel 90860";
|
1998-06-12 20:50:03 +00:00
|
|
|
|
case EM_PPC: return "PowerPC";
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case EM_V800: return "NEC V800";
|
|
|
|
|
case EM_FR20: return "Fujitsu FR20";
|
|
|
|
|
case EM_RH32: return "TRW RH32";
|
|
|
|
|
case EM_MMA: return "Fujitsu MMA";
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_ARM: return "ARM";
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case EM_OLD_ALPHA: return "Digital Alpha (old)";
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_SH: return "Hitachi SH";
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case EM_SPARCV9: return "Sparc v9";
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_ALPHA: return "Alpha";
|
|
|
|
|
case EM_CYGNUS_D10V: return "d10v";
|
1998-06-13 15:15:13 +00:00
|
|
|
|
/* start-sanitize-d30v */
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_CYGNUS_D30V: return "d30v";
|
1998-06-13 15:15:13 +00:00
|
|
|
|
/* end-sanitize-d30v */
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case EM_CYGNUS_M32R: return "M32r";
|
|
|
|
|
case EM_CYGNUS_V850: return "v850";
|
|
|
|
|
case EM_CYGNUS_MN10300: return "mn10300";
|
|
|
|
|
case EM_CYGNUS_MN10200: return "mn10200";
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
sprintf (buff, _("<unknown>: %x"), e_machine);
|
|
|
|
|
return buff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-12 20:50:03 +00:00
|
|
|
|
static char *
|
|
|
|
|
get_machine_flags (e_flags, e_machine)
|
|
|
|
|
unsigned e_flags;
|
|
|
|
|
unsigned e_machine;
|
|
|
|
|
{
|
|
|
|
|
static char buf [1024];
|
|
|
|
|
|
|
|
|
|
buf[0] = '\0';
|
|
|
|
|
if (e_flags)
|
|
|
|
|
{
|
|
|
|
|
switch (e_machine)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EM_PPC:
|
|
|
|
|
if (e_flags & EF_PPC_EMB)
|
|
|
|
|
strcat (buf, ", emb");
|
|
|
|
|
|
|
|
|
|
if (e_flags & EF_PPC_RELOCATABLE)
|
|
|
|
|
strcat (buf, ", relocatable");
|
|
|
|
|
|
|
|
|
|
if (e_flags & EF_PPC_RELOCATABLE_LIB)
|
|
|
|
|
strcat (buf, ", relocatable-lib");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EM_CYGNUS_M32R:
|
|
|
|
|
if ((e_flags & EF_M32R_ARCH) == E_M32R_ARCH)
|
|
|
|
|
strcat (buf, ", m32r");
|
|
|
|
|
|
|
|
|
|
/* start-sanitize-m32rx */
|
|
|
|
|
#ifdef E_M32RX_ARCH
|
|
|
|
|
if ((e_flags & EF_M32R_ARCH) == E_M32RX_ARCH)
|
|
|
|
|
strcat (buf, ", m32rx");
|
|
|
|
|
#endif
|
|
|
|
|
/* end-sanitize-m32rx */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EM_MIPS:
|
|
|
|
|
case EM_MIPS_RS4_BE:
|
|
|
|
|
if (e_flags & EF_MIPS_NOREORDER)
|
|
|
|
|
strcat (buf, ", noreorder");
|
|
|
|
|
|
|
|
|
|
if (e_flags & EF_MIPS_PIC)
|
|
|
|
|
strcat (buf, ", pic");
|
|
|
|
|
|
|
|
|
|
if (e_flags & EF_MIPS_CPIC)
|
|
|
|
|
strcat (buf, ", cpic");
|
|
|
|
|
|
|
|
|
|
if (e_flags & EF_MIPS_ABI2)
|
|
|
|
|
strcat (buf, ", abi2");
|
|
|
|
|
|
|
|
|
|
if ((e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_1)
|
|
|
|
|
strcat (buf, ", mips1");
|
|
|
|
|
|
|
|
|
|
if ((e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_2)
|
|
|
|
|
strcat (buf, ", mips2");
|
|
|
|
|
|
|
|
|
|
if ((e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_3)
|
|
|
|
|
strcat (buf, ", mips3");
|
|
|
|
|
|
|
|
|
|
if ((e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_4)
|
|
|
|
|
strcat (buf, ", mips4");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_machine_data (e_data)
|
|
|
|
|
unsigned e_data;
|
|
|
|
|
{
|
|
|
|
|
static char buff [32];
|
|
|
|
|
|
|
|
|
|
switch (e_data)
|
|
|
|
|
{
|
|
|
|
|
case ELFDATA2LSB: return _("ELFDATA2LSB (little endian)");
|
|
|
|
|
case ELFDATA2MSB: return _("ELFDATA2MSB (big endian)");
|
|
|
|
|
default:
|
|
|
|
|
sprintf (buff, _("<unknown>: %x"), e_data);
|
|
|
|
|
return buff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-11 21:51:56 +00:00
|
|
|
|
static char *
|
|
|
|
|
get_segment_type (p_type)
|
|
|
|
|
unsigned long p_type;
|
|
|
|
|
{
|
|
|
|
|
static char buff [32];
|
|
|
|
|
|
|
|
|
|
switch (p_type)
|
|
|
|
|
{
|
|
|
|
|
case PT_NULL: return _("Unused");
|
|
|
|
|
case PT_LOAD: return _("Loadable");
|
|
|
|
|
case PT_DYNAMIC: return _("Dynamic link info");
|
|
|
|
|
case PT_INTERP: return _("Interpreter");
|
|
|
|
|
case PT_NOTE: return _("Auxillary Info");
|
|
|
|
|
case PT_SHLIB: return _("Shared Library");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case PT_PHDR: return _("Program Header");
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
|
|
|
|
|
return _("processor specific");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf (buff, _("<unknown>: %x"), p_type);
|
|
|
|
|
return buff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_section_type_name (sh_type)
|
|
|
|
|
unsigned int sh_type;
|
|
|
|
|
{
|
|
|
|
|
static char buff [32];
|
|
|
|
|
|
|
|
|
|
switch (sh_type)
|
|
|
|
|
{
|
|
|
|
|
case SHT_NULL: return _("Unused");
|
|
|
|
|
case SHT_PROGBITS: return _("Program data");
|
|
|
|
|
case SHT_SYMTAB: return _("Symbol table");
|
|
|
|
|
case SHT_STRTAB: return _("String table");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case SHT_RELA: return _("Relocations");
|
|
|
|
|
case SHT_HASH: return _("Symbol hashes");
|
|
|
|
|
case SHT_DYNAMIC: return _("Dynamic info");
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case SHT_NOTE: return _("Notes");
|
|
|
|
|
case SHT_NOBITS: return _("Space, no data");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case SHT_REL: return _("Relocations");
|
|
|
|
|
case SHT_SHLIB: return _("Shared lib info");
|
|
|
|
|
case SHT_DYNSYM: return _("Dynamic symbols");
|
1998-06-11 21:51:56 +00:00
|
|
|
|
case SHT_GNU_verdef: return _("Version definition");
|
|
|
|
|
case SHT_GNU_verneed: return _("Version needs");
|
|
|
|
|
case SHT_GNU_versym: return _("Version symbols");
|
|
|
|
|
case 0x6ffffff0: return "VERSYM";
|
|
|
|
|
case 0x6ffffffc: return "VERDEF";
|
|
|
|
|
case 0x7ffffffd: return "AUXILIARY";
|
|
|
|
|
case 0x7fffffff: return "FILTER";
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC))
|
1998-06-23 18:12:44 +00:00
|
|
|
|
sprintf (buff, _("cpu defined (%d)"), sh_type - SHT_LOPROC);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
else if ((sh_type >= SHT_LOUSER) && (sh_type <= SHT_HIUSER))
|
1998-06-23 18:12:44 +00:00
|
|
|
|
sprintf (buff, _("app defined (%d)"), sh_type - SHT_LOUSER);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
else
|
1998-06-23 18:12:44 +00:00
|
|
|
|
sprintf (buff, _("<unknown>: %x"), sh_type);
|
|
|
|
|
return buff;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct option options [] =
|
|
|
|
|
{
|
|
|
|
|
{"all", no_argument, 0, 'a'},
|
|
|
|
|
{"file-header", no_argument, 0, 'h'},
|
|
|
|
|
{"program-headers", no_argument, 0, 'l'},
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{"headers", no_argument, 0, 'e'},
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{"segments", no_argument, 0, 'l'},
|
|
|
|
|
{"sections", no_argument, 0, 'S'},
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{"section-headers", no_argument, 0, 'S'},
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{"symbols", no_argument, 0, 's'},
|
|
|
|
|
{"relocs", no_argument, 0, 'r'},
|
|
|
|
|
{"dynamic", no_argument, 0, 'd'},
|
|
|
|
|
{"version-info", no_argument, 0, 'V'},
|
|
|
|
|
{"use-dynamic", no_argument, 0, 'D'},
|
|
|
|
|
|
|
|
|
|
{"hex-dump", required_argument, 0, 'x'},
|
|
|
|
|
#ifdef SUPPORT_DISASSEMBLY
|
|
|
|
|
{"instruction-dump", required_argument, 0, 'i'},
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
{"version", no_argument, 0, 'v'},
|
|
|
|
|
{"help", no_argument, 0, 'H'},
|
|
|
|
|
|
|
|
|
|
{0, no_argument, 0, 0}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
usage ()
|
|
|
|
|
{
|
1998-06-22 22:28:49 +00:00
|
|
|
|
fprintf (stdout, _("Usage: readelf {options} elf-file(s)\n"));
|
|
|
|
|
fprintf (stdout, _(" Options are:\n"));
|
1998-06-23 18:12:44 +00:00
|
|
|
|
fprintf (stdout, _(" -a or --all Equivalent to: -h -l -S -s -r -d -V\n"));
|
1998-06-22 22:28:49 +00:00
|
|
|
|
fprintf (stdout, _(" -h or --file-header Display the ELF file header\n"));
|
|
|
|
|
fprintf (stdout, _(" -l or --program-headers or --segments\n"));
|
|
|
|
|
fprintf (stdout, _(" Display the program headers\n"));
|
1998-06-23 18:12:44 +00:00
|
|
|
|
fprintf (stdout, _(" -S or --section-headers or --sections\n"));
|
|
|
|
|
fprintf (stdout, _(" Display the sections' header\n"));
|
|
|
|
|
fprintf (stdout, _(" -e or --headers Equivalent to: -h -l -S\n"));
|
1998-06-22 22:28:49 +00:00
|
|
|
|
fprintf (stdout, _(" -s or --symbols Display the symbol table\n"));
|
|
|
|
|
fprintf (stdout, _(" -r or --relocs Display the relocations (if present)\n"));
|
1998-06-23 18:12:44 +00:00
|
|
|
|
fprintf (stdout, _(" -d or --dynamic Display the dynamic segment (if present)\n"));
|
1998-06-22 22:28:49 +00:00
|
|
|
|
fprintf (stdout, _(" -V or --version-info Display the version sections (if present)\n"));
|
|
|
|
|
fprintf (stdout, _(" -D or --use-dynamic Use the dynamic section info when displaying symbols\n"));
|
|
|
|
|
fprintf (stdout, _(" -x <number> or --hex-dump=<number>\n"));
|
|
|
|
|
fprintf (stdout, _(" Dump the contents of section <number>\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
#ifdef SUPPORT_DISASSEMBLY
|
1998-06-22 22:28:49 +00:00
|
|
|
|
fprintf (stdout, _(" -i <number> or --instruction-dump=<number>\n"));
|
|
|
|
|
fprintf (stdout, _(" Disassemble the contents of section <number>\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
#endif
|
1998-06-22 22:28:49 +00:00
|
|
|
|
fprintf (stdout, _(" -v or --version Display the version number of readelf\n"));
|
|
|
|
|
fprintf (stdout, _(" -H or --help Display this information\n"));
|
|
|
|
|
fprintf (stdout, _("Report bugs to bug-gnu-utils@gnu.org\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
exit (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
parse_args (argc, argv)
|
|
|
|
|
int argc;
|
|
|
|
|
char ** argv;
|
|
|
|
|
{
|
1998-06-22 22:28:49 +00:00
|
|
|
|
int c;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-11 21:51:56 +00:00
|
|
|
|
if (argc < 2)
|
|
|
|
|
usage ();
|
|
|
|
|
|
|
|
|
|
while ((c = getopt_long
|
1998-06-23 18:12:44 +00:00
|
|
|
|
(argc, argv, "ersahldSDx:i:vV", options, NULL)) != EOF)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
char * cp;
|
|
|
|
|
int section;
|
|
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case 'H':
|
|
|
|
|
usage ();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'a':
|
1998-06-23 18:12:44 +00:00
|
|
|
|
do_syms ++;
|
|
|
|
|
do_reloc ++;
|
|
|
|
|
do_dynamic ++;
|
|
|
|
|
do_header ++;
|
|
|
|
|
do_sections ++;
|
|
|
|
|
do_segments ++;
|
|
|
|
|
do_version ++;
|
|
|
|
|
break;
|
|
|
|
|
case 'e':
|
|
|
|
|
do_header ++;
|
|
|
|
|
do_sections ++;
|
|
|
|
|
do_segments ++;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'D':
|
1998-06-23 18:12:44 +00:00
|
|
|
|
do_using_dynamic ++;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'r':
|
1998-06-23 18:12:44 +00:00
|
|
|
|
do_reloc ++;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'h':
|
1998-06-23 18:12:44 +00:00
|
|
|
|
do_header ++;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'l':
|
1998-06-23 18:12:44 +00:00
|
|
|
|
do_segments ++;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
case 's':
|
1998-06-23 18:12:44 +00:00
|
|
|
|
do_syms ++;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'S':
|
1998-06-23 18:12:44 +00:00
|
|
|
|
do_sections ++;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'd':
|
1998-06-23 18:12:44 +00:00
|
|
|
|
do_dynamic ++;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'x':
|
|
|
|
|
do_dump ++;
|
|
|
|
|
section = strtoul (optarg, & cp, 0);
|
|
|
|
|
if (! * cp && section >= 0 && section < NUM_DUMP_SECTS)
|
|
|
|
|
{
|
|
|
|
|
dump_sects [section] |= HEX_DUMP;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
goto oops;
|
|
|
|
|
#ifdef SUPPORT_DISASSEMBLY
|
|
|
|
|
case 'i':
|
|
|
|
|
do_dump ++;
|
|
|
|
|
section = strtoul (optarg, & cp, 0);
|
|
|
|
|
if (! * cp && section >= 0 && section < NUM_DUMP_SECTS)
|
|
|
|
|
{
|
|
|
|
|
dump_sects [section] |= DISASS_DUMP;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
goto oops;
|
|
|
|
|
#endif
|
|
|
|
|
case 'v':
|
|
|
|
|
print_version (program_name);
|
|
|
|
|
break;
|
|
|
|
|
case 'V':
|
|
|
|
|
do_version ++;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
oops:
|
|
|
|
|
/* xgettext:c-format */
|
|
|
|
|
error (_("Invalid option '-%c'\n"), c);
|
|
|
|
|
/* Drop through. */
|
|
|
|
|
case '?':
|
|
|
|
|
usage ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (!do_dynamic && !do_syms && !do_reloc && !do_sections
|
|
|
|
|
&& !do_segments && !do_header && !do_dump && !do_version)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
usage ();
|
|
|
|
|
else if (argc < 3)
|
1998-06-22 22:28:49 +00:00
|
|
|
|
{
|
|
|
|
|
warn (_("Nothing to do.\n"));
|
|
|
|
|
usage();
|
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
/* Decode the data held in 'elf_header'. */
|
1998-06-11 21:51:56 +00:00
|
|
|
|
static int
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_file_header ()
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if ( elf_header.e_ident [EI_MAG0] != ELFMAG0
|
|
|
|
|
|| elf_header.e_ident [EI_MAG1] != ELFMAG1
|
|
|
|
|
|| elf_header.e_ident [EI_MAG2] != ELFMAG2
|
|
|
|
|
|| elf_header.e_ident [EI_MAG3] != ELFMAG3)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
error
|
|
|
|
|
(_("Not an ELF file - it has the wrong magic bytes at the start\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (elf_header.e_ident [EI_CLASS] != ELFCLASS32)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
error (_("Not a 32 bit ELF file\n"));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (do_header)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (_("ELF Header:\n"));
|
|
|
|
|
printf (_(" Magic: "));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
for (i = 0; i < EI_NIDENT; i ++)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf ("%2.2x ", elf_header.e_ident [i]);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
printf ("\n");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (_(" Type: %s\n"),
|
|
|
|
|
get_file_type (elf_header.e_type));
|
|
|
|
|
printf (_(" Machine: %s\n"),
|
|
|
|
|
get_machine_name (elf_header.e_machine));
|
|
|
|
|
printf (_(" Version: 0x%lx\n"),
|
|
|
|
|
(unsigned long) elf_header.e_version);
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_(" Data: %s\n"),
|
1998-06-23 18:12:44 +00:00
|
|
|
|
get_machine_data (elf_header.e_ident [EI_DATA]));
|
|
|
|
|
printf (_(" Entry point address: 0x%lx\n"),
|
|
|
|
|
(unsigned long) elf_header.e_entry);
|
|
|
|
|
printf (_(" Start of program headers: %ld (bytes into file)\n"),
|
|
|
|
|
(long) elf_header.e_phoff);
|
|
|
|
|
printf (_(" Start of section headers: %ld (bytes into file)\n"),
|
|
|
|
|
(long) elf_header.e_shoff);
|
|
|
|
|
printf (_(" Flags: 0x%lx%s\n"),
|
|
|
|
|
(unsigned long) elf_header.e_flags,
|
|
|
|
|
get_machine_flags (elf_header.e_flags, elf_header.e_machine));
|
|
|
|
|
printf (_(" Size of this header: %ld (bytes)\n"),
|
|
|
|
|
(long) elf_header.e_ehsize);
|
|
|
|
|
printf (_(" Size of program headers: %ld (bytes)\n"),
|
|
|
|
|
(long) elf_header.e_phentsize);
|
|
|
|
|
printf (_(" Number of program headers: %ld\n"),
|
|
|
|
|
(long) elf_header.e_phnum);
|
|
|
|
|
printf (_(" Size of section headers: %ld (bytes)\n"),
|
|
|
|
|
(long) elf_header.e_shentsize);
|
|
|
|
|
printf (_(" Number of section headers: %ld\n"),
|
|
|
|
|
(long) elf_header.e_shnum);
|
|
|
|
|
printf (_(" Section header string table index: %ld\n"),
|
|
|
|
|
(long) elf_header.e_shstrndx);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_program_headers (file)
|
|
|
|
|
FILE * file;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf32_External_Phdr * phdrs;
|
|
|
|
|
Elf32_Internal_Phdr * program_headers;
|
|
|
|
|
Elf32_Internal_Phdr * segment;
|
|
|
|
|
unsigned int i;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (elf_header.e_phnum == 0)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (do_segments)
|
|
|
|
|
printf (_("\nThere are no program headers in this file.\n"));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 1;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (do_segments && !do_header)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (_("\nElf file is %s\n"), get_file_type (elf_header.e_type));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_("Entry point 0x%lx\n"), (unsigned long) elf_header.e_entry);
|
|
|
|
|
printf (_("There are %d program headers, starting at offset %lx:\n"),
|
|
|
|
|
elf_header.e_phnum, (unsigned long) elf_header.e_phoff);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA_ALLOC (elf_header.e_phoff,
|
|
|
|
|
elf_header.e_phentsize * elf_header.e_phnum,
|
|
|
|
|
phdrs, Elf32_External_Phdr *, "program headers");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
program_headers = (Elf32_Internal_Phdr *) malloc
|
|
|
|
|
(elf_header.e_phnum * sizeof (Elf32_Internal_Phdr));
|
|
|
|
|
|
|
|
|
|
if (program_headers == NULL)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
error (_("Out of memory\n"));
|
|
|
|
|
return 0;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0, segment = program_headers;
|
|
|
|
|
i < elf_header.e_phnum;
|
|
|
|
|
i ++, segment ++)
|
|
|
|
|
{
|
|
|
|
|
segment->p_type = BYTE_GET (phdrs[i].p_type);
|
|
|
|
|
segment->p_offset = BYTE_GET (phdrs[i].p_offset);
|
|
|
|
|
segment->p_vaddr = BYTE_GET (phdrs[i].p_vaddr);
|
|
|
|
|
segment->p_paddr = BYTE_GET (phdrs[i].p_paddr);
|
|
|
|
|
segment->p_filesz = BYTE_GET (phdrs[i].p_filesz);
|
|
|
|
|
segment->p_memsz = BYTE_GET (phdrs[i].p_memsz);
|
|
|
|
|
segment->p_flags = BYTE_GET (phdrs[i].p_flags);
|
|
|
|
|
segment->p_align = BYTE_GET (phdrs[i].p_align);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (phdrs);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (do_segments)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf
|
|
|
|
|
(_("\nProgram Header%s:\n"), elf_header.e_phnum > 1 ? "s" : "");
|
|
|
|
|
printf
|
|
|
|
|
(_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadaddr = -1;
|
|
|
|
|
dynamic_addr = 0;
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
for (i = 0, segment = program_headers;
|
|
|
|
|
i < elf_header.e_phnum;
|
|
|
|
|
i ++, segment ++)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (do_segments)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (" %-16.16s ", get_segment_type (segment->p_type));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf ("0x%5.5lx ", (unsigned long) segment->p_offset);
|
|
|
|
|
printf ("0x%8.8lx ", (unsigned long) segment->p_vaddr);
|
|
|
|
|
printf ("0x%8.8lx ", (unsigned long) segment->p_paddr);
|
|
|
|
|
printf ("0x%5.5lx ", (unsigned long) segment->p_filesz);
|
|
|
|
|
printf ("0x%5.5lx ", (unsigned long) segment->p_memsz);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
printf ("%c%c%c ",
|
1998-06-23 18:12:44 +00:00
|
|
|
|
(segment->p_flags & PF_R ? 'R' : ' '),
|
|
|
|
|
(segment->p_flags & PF_W ? 'W' : ' '),
|
|
|
|
|
(segment->p_flags & PF_X ? 'E' : ' '));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf ("%#lx", (unsigned long) segment->p_align);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
switch (segment->p_type)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case PT_LOAD:
|
|
|
|
|
if (loadaddr == -1)
|
|
|
|
|
loadaddr = (segment->p_vaddr & 0xfffff000)
|
|
|
|
|
- (segment->p_offset & 0xfffff000);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PT_DYNAMIC:
|
1998-06-11 21:51:56 +00:00
|
|
|
|
if (dynamic_addr)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
error (_("more than one dynamic segment\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
dynamic_addr = segment->p_offset;
|
|
|
|
|
dynamic_size = segment->p_filesz;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PT_INTERP:
|
|
|
|
|
if (fseek (file, segment->p_offset, SEEK_SET))
|
|
|
|
|
error (_("Unable to find program interpreter name\n"));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
program_interpreter[0] = 0;
|
|
|
|
|
fscanf (file, "%63s", program_interpreter);
|
|
|
|
|
|
|
|
|
|
if (do_segments)
|
|
|
|
|
printf (_("\n [Requesting program interpreter: %s]"),
|
|
|
|
|
program_interpreter);
|
|
|
|
|
}
|
|
|
|
|
break;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (do_segments)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
putc ('\n', stdout);
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (loadaddr == -1)
|
|
|
|
|
{
|
|
|
|
|
/* Very strange. */
|
|
|
|
|
loadaddr = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (do_segments && section_headers != NULL)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
printf (_("\n Section to Segment mapping:\n"));
|
|
|
|
|
printf (_(" Segment Sections...\n"));
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
assert (string_table != NULL);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < elf_header.e_phnum; i++)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
int j;
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf32_Internal_Shdr * section;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
segment = program_headers + i;
|
|
|
|
|
section = section_headers;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
printf (" %2.2d ", i);
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
for (j = 0; j < elf_header.e_shnum; j++, section ++)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (section->sh_size > 0
|
|
|
|
|
/* Compare allocated sections by VMA, unallocated
|
|
|
|
|
sections by file offset. */
|
|
|
|
|
&& (section->sh_flags & SHF_ALLOC
|
|
|
|
|
? (section->sh_addr >= segment->p_vaddr
|
|
|
|
|
&& section->sh_addr + section->sh_size
|
|
|
|
|
<= segment->p_vaddr + segment->p_memsz)
|
|
|
|
|
: (section->sh_offset >= segment->p_offset
|
|
|
|
|
&& (section->sh_offset + section->sh_size
|
|
|
|
|
<= segment->p_offset + segment->p_filesz))))
|
|
|
|
|
printf ("%s ", SECTION_NAME (section));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
putc ('\n',stdout);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
free (program_headers);
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int
|
|
|
|
|
get_section_headers (file)
|
|
|
|
|
FILE * file;
|
|
|
|
|
{
|
|
|
|
|
Elf32_External_Shdr * shdrs;
|
|
|
|
|
Elf32_Internal_Shdr * internal;
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (elf_header.e_shoff,
|
|
|
|
|
elf_header.e_shentsize * elf_header.e_shnum,
|
|
|
|
|
shdrs, Elf32_External_Shdr *, "section headers");
|
|
|
|
|
|
|
|
|
|
section_headers = (Elf32_Internal_Shdr *) malloc
|
|
|
|
|
(elf_header.e_shnum * sizeof (Elf32_Internal_Shdr));
|
|
|
|
|
|
|
|
|
|
if (section_headers == NULL)
|
|
|
|
|
{
|
|
|
|
|
error (_("Out of memory\n"));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0, internal = section_headers;
|
|
|
|
|
i < elf_header.e_shnum;
|
|
|
|
|
i ++, internal ++)
|
|
|
|
|
{
|
|
|
|
|
internal->sh_name = BYTE_GET (shdrs[i].sh_name);
|
|
|
|
|
internal->sh_type = BYTE_GET (shdrs[i].sh_type);
|
|
|
|
|
internal->sh_flags = BYTE_GET (shdrs[i].sh_flags);
|
|
|
|
|
internal->sh_addr = BYTE_GET (shdrs[i].sh_addr);
|
|
|
|
|
internal->sh_offset = BYTE_GET (shdrs[i].sh_offset);
|
|
|
|
|
internal->sh_size = BYTE_GET (shdrs[i].sh_size);
|
|
|
|
|
internal->sh_link = BYTE_GET (shdrs[i].sh_link);
|
|
|
|
|
internal->sh_info = BYTE_GET (shdrs[i].sh_info);
|
|
|
|
|
internal->sh_addralign = BYTE_GET (shdrs[i].sh_addralign);
|
|
|
|
|
internal->sh_entsize = BYTE_GET (shdrs[i].sh_entsize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (shdrs);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Elf_Internal_Sym *
|
|
|
|
|
get_elf_symbols (file, offset, number)
|
|
|
|
|
FILE * file;
|
|
|
|
|
unsigned long offset;
|
|
|
|
|
unsigned long number;
|
|
|
|
|
{
|
|
|
|
|
Elf32_External_Sym * esyms;
|
|
|
|
|
Elf_Internal_Sym * isyms;
|
|
|
|
|
Elf_Internal_Sym * psym;
|
|
|
|
|
unsigned int j;
|
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (offset, number * sizeof (Elf32_External_Sym),
|
|
|
|
|
esyms, Elf32_External_Sym *, "symbols");
|
|
|
|
|
|
|
|
|
|
isyms = (Elf_Internal_Sym *) malloc (number * sizeof (Elf_Internal_Sym));
|
|
|
|
|
|
|
|
|
|
if (isyms == NULL)
|
|
|
|
|
{
|
|
|
|
|
error (_("Out of memory\n"));
|
|
|
|
|
free (esyms);
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (j = 0, psym = isyms;
|
|
|
|
|
j < number;
|
|
|
|
|
j ++, psym ++)
|
|
|
|
|
{
|
|
|
|
|
psym->st_name = BYTE_GET (esyms[j].st_name);
|
|
|
|
|
psym->st_value = BYTE_GET (esyms[j].st_value);
|
|
|
|
|
psym->st_size = BYTE_GET (esyms[j].st_size);
|
|
|
|
|
psym->st_shndx = BYTE_GET (esyms[j].st_shndx);
|
|
|
|
|
psym->st_info = BYTE_GET (esyms[j].st_info);
|
|
|
|
|
psym->st_other = BYTE_GET (esyms[j].st_other);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (esyms);
|
|
|
|
|
|
|
|
|
|
return isyms;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_section_headers (file)
|
|
|
|
|
FILE * file;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf32_Internal_Shdr * section;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
int i;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
section_headers = NULL;
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (elf_header.e_shnum == 0)
|
|
|
|
|
{
|
|
|
|
|
if (do_sections)
|
|
|
|
|
printf (_("\nThere are no sections in this file.\n"));
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 1;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (do_sections && !do_header)
|
|
|
|
|
printf (_("There are %d section headers, starting at offset %x:\n"),
|
|
|
|
|
elf_header.e_shnum, elf_header.e_shoff);
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (! get_section_headers (file))
|
|
|
|
|
return 0;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
/* Read in the string table, so that we have names to display. */
|
|
|
|
|
section = section_headers + elf_header.e_shstrndx;
|
|
|
|
|
|
|
|
|
|
if (section->sh_size != 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned long string_table_offset;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
string_table_offset = section->sh_offset;
|
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (section->sh_offset, section->sh_size,
|
|
|
|
|
string_table, char *, "string table");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Scan the sections for the dynamic symbol table
|
|
|
|
|
and dynamic string table. */
|
|
|
|
|
dynamic_symbols = NULL;
|
|
|
|
|
dynamic_strings = NULL;
|
|
|
|
|
for (i = 0, section = section_headers;
|
|
|
|
|
i < elf_header.e_shnum;
|
|
|
|
|
i ++, section ++)
|
|
|
|
|
{
|
|
|
|
|
if (section->sh_type == SHT_DYNSYM)
|
|
|
|
|
{
|
|
|
|
|
if (dynamic_symbols != NULL)
|
|
|
|
|
{
|
|
|
|
|
error (_("File contains multiple dynamic symbol tables\n"));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
dynamic_symbols = get_elf_symbols
|
|
|
|
|
(file, section->sh_offset, section->sh_size / section->sh_entsize);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
else if (section->sh_type == SHT_STRTAB
|
|
|
|
|
&& strcmp (SECTION_NAME (section), ".dynstr") == 0)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (dynamic_strings != NULL)
|
|
|
|
|
{
|
|
|
|
|
error (_("File contains multiple dynamic string tables\n"));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
GET_DATA_ALLOC (section->sh_offset, section->sh_size,
|
|
|
|
|
dynamic_strings, char *, "dynamic strings");
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (! do_sections)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 1;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (_("\nSection Header%s:\n"), elf_header.e_shnum > 1 ? "s" : "");
|
|
|
|
|
printf
|
1998-07-01 23:30:34 +00:00
|
|
|
|
(_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
for (i = 0, section = section_headers;
|
|
|
|
|
i < elf_header.e_shnum;
|
|
|
|
|
i ++, section ++)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (" [%2d] %-17.17s %-15.15s ",
|
|
|
|
|
i,
|
|
|
|
|
SECTION_NAME (section),
|
|
|
|
|
get_section_type_name (section->sh_type));
|
|
|
|
|
|
1998-06-12 00:56:39 +00:00
|
|
|
|
printf ( "%8.8lx %6.6lx %6.6lx %2.2lx",
|
1998-06-30 00:03:05 +00:00
|
|
|
|
(unsigned long) section->sh_addr,
|
|
|
|
|
(unsigned long) section->sh_offset,
|
|
|
|
|
(unsigned long) section->sh_size,
|
|
|
|
|
(unsigned long) section->sh_entsize);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (" %c%c%c %2ld %3lx %ld \n",
|
1998-06-23 18:12:44 +00:00
|
|
|
|
(section->sh_flags & SHF_WRITE ? 'W' : ' '),
|
|
|
|
|
(section->sh_flags & SHF_ALLOC ? 'A' : ' '),
|
|
|
|
|
(section->sh_flags & SHF_EXECINSTR ? 'X' : ' '),
|
1998-06-30 00:03:05 +00:00
|
|
|
|
(unsigned long) section->sh_link,
|
|
|
|
|
(unsigned long) section->sh_info,
|
|
|
|
|
(unsigned long) section->sh_addralign);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
/* Process the reloc section. */
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_relocs (file)
|
|
|
|
|
FILE * file;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
unsigned long rel_size;
|
|
|
|
|
unsigned long rel_offset;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (!do_reloc)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 1;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (do_using_dynamic)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rel_size = 0;
|
|
|
|
|
rel_offset = 0;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (dynamic_info [DT_REL])
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rel_offset = dynamic_info [DT_REL];
|
|
|
|
|
rel_size = dynamic_info [DT_RELSZ];
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
1998-06-23 18:12:44 +00:00
|
|
|
|
else if (dynamic_info [DT_RELA])
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
rel_offset = dynamic_info [DT_RELA];
|
|
|
|
|
rel_size = dynamic_info [DT_RELASZ];
|
|
|
|
|
}
|
|
|
|
|
else if (dynamic_info [DT_JMPREL])
|
|
|
|
|
{
|
|
|
|
|
rel_offset = dynamic_info [DT_JMPREL];
|
|
|
|
|
rel_size = dynamic_info [DT_PLTRELSZ];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rel_size)
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf
|
|
|
|
|
(_("\nRelocation section at offset 0x%x contains %d bytes:\n"),
|
|
|
|
|
rel_offset, rel_size);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
dump_relocations (file, rel_offset - loadaddr, rel_size,
|
|
|
|
|
dynamic_symbols, dynamic_strings);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
1998-06-23 18:12:44 +00:00
|
|
|
|
else
|
|
|
|
|
printf (_("\nThere are no dynamic relocations in this file.\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf32_Internal_Shdr * section;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
unsigned long i;
|
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
|
|
assert (string_table != NULL);
|
|
|
|
|
|
|
|
|
|
for (i = 0, section = section_headers;
|
|
|
|
|
i < elf_header.e_shnum;
|
|
|
|
|
i++, section ++)
|
|
|
|
|
{
|
|
|
|
|
if ( section->sh_type != SHT_RELA
|
|
|
|
|
&& section->sh_type != SHT_REL)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
rel_offset = section->sh_offset;
|
|
|
|
|
rel_size = section->sh_size;
|
|
|
|
|
|
|
|
|
|
if (rel_size)
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf32_Internal_Shdr * strsec;
|
|
|
|
|
Elf32_Internal_Shdr * symsec;
|
|
|
|
|
Elf_Internal_Sym * symtab;
|
|
|
|
|
char * strtab;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf
|
|
|
|
|
(_("\nRelocation section '%s' at offset 0x%x contains %d entries:\n"),
|
|
|
|
|
SECTION_NAME (section), rel_offset,
|
|
|
|
|
rel_size / section->sh_entsize);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
symsec = section_headers + section->sh_link;
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
symtab = get_elf_symbols (file, symsec->sh_offset,
|
|
|
|
|
symsec->sh_size / symsec->sh_entsize);
|
|
|
|
|
|
|
|
|
|
if (symtab == NULL)
|
|
|
|
|
continue;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
strsec = section_headers + symsec->sh_link;
|
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (strsec->sh_offset, strsec->sh_size, strtab,
|
|
|
|
|
char *, "string table");
|
|
|
|
|
|
|
|
|
|
dump_relocations (file, rel_offset, rel_size, symtab, strtab);
|
|
|
|
|
|
|
|
|
|
free (strtab);
|
|
|
|
|
free (symtab);
|
|
|
|
|
|
|
|
|
|
found = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! found)
|
|
|
|
|
printf (_("\nThere are no relocations in this file.\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
/* Parse the dynamic segment */
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_dynamic_segment (file)
|
|
|
|
|
FILE * file;
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_Internal_Dyn * dynamic_segment;
|
|
|
|
|
Elf_Internal_Dyn * entry;
|
|
|
|
|
Elf32_External_Dyn * edyn;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
unsigned int i;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (dynamic_size == 0)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (do_dynamic)
|
|
|
|
|
printf (_("\nThere is no dynamic segment in this file.\n"));
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 1;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (dynamic_addr, dynamic_size,
|
1998-06-30 00:03:05 +00:00
|
|
|
|
edyn, Elf32_External_Dyn *, "dynamic segment");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
dynamic_size = dynamic_size / sizeof (Elf32_External_Dyn);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
dynamic_segment = (Elf_Internal_Dyn *)
|
|
|
|
|
malloc (dynamic_size * sizeof (Elf_Internal_Dyn));
|
|
|
|
|
|
|
|
|
|
if (dynamic_segment == NULL)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
error (_("Out of memory\n"));
|
|
|
|
|
free (edyn);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0, entry = dynamic_segment;
|
|
|
|
|
i < dynamic_size;
|
|
|
|
|
i ++, entry ++)
|
|
|
|
|
{
|
|
|
|
|
entry->d_tag = BYTE_GET (edyn [i].d_tag);
|
|
|
|
|
entry->d_un.d_val = BYTE_GET (edyn [i].d_un.d_val);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
free (edyn);
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
/* Find the appropriate symbol table. */
|
|
|
|
|
if (dynamic_symbols == NULL)
|
|
|
|
|
{
|
|
|
|
|
for (i = 0, entry = dynamic_segment;
|
|
|
|
|
i < dynamic_size;
|
|
|
|
|
++i, ++ entry)
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned long offset;
|
|
|
|
|
long num_syms;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (entry->d_tag != DT_SYMTAB)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
dynamic_info [DT_SYMTAB] = entry->d_un.d_val;
|
|
|
|
|
|
|
|
|
|
/* Since we do not know how big the symbol table is,
|
|
|
|
|
we default to reading in the entire file (!) and
|
|
|
|
|
processing that. This is overkill, I know, but it
|
|
|
|
|
should work. */
|
|
|
|
|
|
|
|
|
|
offset = entry->d_un.d_val - loadaddr;
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (fseek (file, 0, SEEK_END))
|
|
|
|
|
error (_("Unable to seek to end of file!"));
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
num_syms = (ftell (file) - offset) / sizeof (Elf32_External_Sym);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (num_syms < 1)
|
|
|
|
|
{
|
|
|
|
|
error (_("Unable to determine the number of symbols to load\n"));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
dynamic_symbols = get_elf_symbols (file, offset, num_syms);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Similarly find a string table. */
|
|
|
|
|
if (dynamic_strings == NULL)
|
|
|
|
|
{
|
|
|
|
|
for (i = 0, entry = dynamic_segment;
|
|
|
|
|
i < dynamic_size;
|
|
|
|
|
++i, ++ entry)
|
|
|
|
|
{
|
|
|
|
|
unsigned long offset;
|
|
|
|
|
long str_tab_len;
|
|
|
|
|
|
|
|
|
|
if (entry->d_tag != DT_STRTAB)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
dynamic_info [DT_STRTAB] = entry->d_un.d_val;
|
|
|
|
|
|
|
|
|
|
/* Since we do not know how big the string table is,
|
|
|
|
|
we default to reading in the entire file (!) and
|
|
|
|
|
processing that. This is overkill, I know, but it
|
|
|
|
|
should work. */
|
|
|
|
|
|
|
|
|
|
offset = entry->d_un.d_val - loadaddr;
|
|
|
|
|
if (fseek (file, 0, SEEK_END))
|
|
|
|
|
error (_("Unable to seek to end of file\n"));
|
|
|
|
|
str_tab_len = ftell (file) - offset;
|
|
|
|
|
|
|
|
|
|
if (str_tab_len < 1)
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
error
|
|
|
|
|
(_("Unable to determine the length of the dynamic string table\n"));
|
1998-06-23 18:12:44 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (offset, str_tab_len, dynamic_strings, char *,
|
|
|
|
|
"dynamic string table");
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (do_dynamic && dynamic_addr)
|
|
|
|
|
printf (_("\nDynamic segement at offset 0x%x contains %d entries:\n"),
|
|
|
|
|
dynamic_addr, dynamic_size);
|
|
|
|
|
if (do_dynamic)
|
|
|
|
|
printf (_(" Tag Type Name/Value\n"));
|
|
|
|
|
|
|
|
|
|
for (i = 0, entry = dynamic_segment;
|
|
|
|
|
i < dynamic_size;
|
|
|
|
|
i++, entry ++)
|
|
|
|
|
{
|
|
|
|
|
if (do_dynamic)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_(" 0x%-6.6lx (%-11.11s) "),
|
|
|
|
|
(unsigned long) entry->d_tag,
|
1998-06-23 18:12:44 +00:00
|
|
|
|
get_dynamic_type (entry->d_tag));
|
|
|
|
|
|
|
|
|
|
switch (entry->d_tag)
|
|
|
|
|
{
|
|
|
|
|
case DT_AUXILIARY:
|
|
|
|
|
case DT_FILTER:
|
|
|
|
|
if (do_dynamic)
|
|
|
|
|
{
|
|
|
|
|
if (entry->d_tag == DT_AUXILIARY)
|
|
|
|
|
printf (_("Auxiliary library"));
|
|
|
|
|
else
|
|
|
|
|
printf (_("Filter library"));
|
|
|
|
|
|
|
|
|
|
if (dynamic_strings)
|
|
|
|
|
printf (": [%s]\n", dynamic_strings + entry->d_un.d_val);
|
|
|
|
|
else
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (": %#lx\n", (long) entry->d_un.d_val);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
case DT_NULL :
|
|
|
|
|
case DT_NEEDED :
|
|
|
|
|
case DT_PLTRELSZ:
|
|
|
|
|
case DT_PLTGOT :
|
|
|
|
|
case DT_HASH :
|
|
|
|
|
case DT_STRTAB :
|
|
|
|
|
case DT_SYMTAB :
|
|
|
|
|
case DT_RELA :
|
|
|
|
|
case DT_RELASZ :
|
|
|
|
|
case DT_RELAENT :
|
|
|
|
|
case DT_STRSZ :
|
|
|
|
|
case DT_SYMENT :
|
|
|
|
|
case DT_INIT :
|
|
|
|
|
case DT_FINI :
|
|
|
|
|
case DT_SONAME :
|
|
|
|
|
case DT_RPATH :
|
|
|
|
|
case DT_SYMBOLIC:
|
|
|
|
|
case DT_REL :
|
|
|
|
|
case DT_RELSZ :
|
|
|
|
|
case DT_RELENT :
|
|
|
|
|
case DT_PLTREL :
|
|
|
|
|
case DT_DEBUG :
|
|
|
|
|
case DT_TEXTREL :
|
|
|
|
|
case DT_JMPREL :
|
1998-06-23 18:12:44 +00:00
|
|
|
|
dynamic_info [entry->d_tag] = entry->d_un.d_val;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
if (do_dynamic)
|
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
char * name;
|
|
|
|
|
|
|
|
|
|
if (dynamic_strings == NULL)
|
|
|
|
|
name = NULL;
|
|
|
|
|
else
|
|
|
|
|
name = dynamic_strings + entry->d_un.d_val;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (name)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
switch (entry->d_tag)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
case DT_NEEDED:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (_("Shared library: [%s]"), name);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (strcmp (name, program_interpreter))
|
1998-06-11 21:51:56 +00:00
|
|
|
|
printf ("\n");
|
|
|
|
|
else
|
|
|
|
|
printf (_(" program interpreter\n"));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DT_SONAME:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (_("Library soname: [%s]\n"), name);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DT_RPATH:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (_("Library rpath: [%s]\n"), name);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf ("%#lx\n", (long) entry->d_un.d_val);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf ("%#lx\n", (long) entry->d_un.d_val);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if ((entry->d_tag >= DT_VERSYM) && (entry->d_tag <= DT_VERNEEDNUM))
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
version_info [DT_VERSIONTAGIDX (entry->d_tag)] =
|
|
|
|
|
entry->d_un.d_val;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
if (do_dynamic)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf ("%#lx\n", (long) entry->d_un.d_ptr);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (dynamic_segment);
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
1998-07-08 03:55:07 +00:00
|
|
|
|
get_ver_flags (flags)
|
|
|
|
|
unsigned short flags;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
|
|
|
|
static char buff [32];
|
|
|
|
|
|
|
|
|
|
buff[0] = 0;
|
|
|
|
|
|
|
|
|
|
if (flags == 0)
|
|
|
|
|
return _("none");
|
|
|
|
|
|
|
|
|
|
if (flags & VER_FLG_BASE)
|
|
|
|
|
strcat (buff, "BASE ");
|
|
|
|
|
|
|
|
|
|
if (flags & VER_FLG_WEAK)
|
|
|
|
|
{
|
|
|
|
|
if (flags & VER_FLG_BASE)
|
|
|
|
|
strcat (buff, "| ");
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
strcat (buff, "WEAK ");
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (flags & ~(VER_FLG_BASE | VER_FLG_WEAK))
|
|
|
|
|
strcat (buff, "| <unknown>");
|
|
|
|
|
|
|
|
|
|
return buff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Display the contents of the version sections. */
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_version_sections (file)
|
|
|
|
|
FILE * file;
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf32_Internal_Shdr * section;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
unsigned i;
|
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
|
|
if (! do_version)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 1;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0, section = section_headers;
|
|
|
|
|
i < elf_header.e_shnum;
|
|
|
|
|
i++, section ++)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
switch (section->sh_type)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case SHT_GNU_verdef:
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_External_Verdef * edefs;
|
|
|
|
|
unsigned int idx;
|
|
|
|
|
unsigned int cnt;
|
|
|
|
|
|
|
|
|
|
found = 1;
|
|
|
|
|
|
|
|
|
|
printf
|
|
|
|
|
(_("\nVersion definition section '%s' contains %d entries:\n"),
|
|
|
|
|
SECTION_NAME (section), section->sh_info);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
printf (_(" Addr: %#08x Offset: %#08x Link: %x (%s)\n"),
|
|
|
|
|
section->sh_addr, section->sh_offset, section->sh_link,
|
|
|
|
|
SECTION_NAME (section_headers + section->sh_link));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
GET_DATA_ALLOC (section->sh_offset, section->sh_size,
|
1998-06-30 00:03:05 +00:00
|
|
|
|
edefs, Elf_External_Verdef *,
|
1998-06-23 18:12:44 +00:00
|
|
|
|
"version definition section");
|
|
|
|
|
|
|
|
|
|
for (idx = cnt = 0; cnt < section->sh_info; ++ cnt)
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
char * vstart;
|
|
|
|
|
Elf_External_Verdef * edef;
|
|
|
|
|
Elf_Internal_Verdef ent;
|
|
|
|
|
Elf_External_Verdaux * eaux;
|
|
|
|
|
Elf_Internal_Verdaux aux;
|
|
|
|
|
int j;
|
|
|
|
|
int isum;
|
|
|
|
|
|
|
|
|
|
vstart = ((char *) edefs) + idx;
|
|
|
|
|
|
|
|
|
|
edef = (Elf_External_Verdef *) vstart;
|
|
|
|
|
|
|
|
|
|
ent.vd_version = BYTE_GET (edef->vd_version);
|
|
|
|
|
ent.vd_flags = BYTE_GET (edef->vd_flags);
|
|
|
|
|
ent.vd_ndx = BYTE_GET (edef->vd_ndx);
|
|
|
|
|
ent.vd_cnt = BYTE_GET (edef->vd_cnt);
|
|
|
|
|
ent.vd_hash = BYTE_GET (edef->vd_hash);
|
|
|
|
|
ent.vd_aux = BYTE_GET (edef->vd_aux);
|
|
|
|
|
ent.vd_next = BYTE_GET (edef->vd_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
printf (_(" %#06x: Rev: %d Flags: %s"),
|
1998-06-30 00:03:05 +00:00
|
|
|
|
idx, ent.vd_version, get_ver_flags (ent.vd_flags));
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_(" Index: %ld Cnt: %ld "), ent.vd_ndx, ent.vd_cnt);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
vstart += ent.vd_aux;
|
|
|
|
|
|
|
|
|
|
eaux = (Elf_External_Verdaux *) vstart;
|
|
|
|
|
|
|
|
|
|
aux.vda_name = BYTE_GET (eaux->vda_name);
|
|
|
|
|
aux.vda_next = BYTE_GET (eaux->vda_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (dynamic_strings)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_("Name: %s\n"), dynamic_strings + aux.vda_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
else
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_("Name index: %ld\n"), aux.vda_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
isum = idx + ent.vd_aux;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
for (j = 1; j < ent.vd_cnt; j ++)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
isum += aux.vda_next;
|
|
|
|
|
vstart += aux.vda_next;
|
|
|
|
|
|
|
|
|
|
eaux = (Elf_External_Verdaux *) vstart;
|
|
|
|
|
|
|
|
|
|
aux.vda_name = BYTE_GET (eaux->vda_name);
|
|
|
|
|
aux.vda_next = BYTE_GET (eaux->vda_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (dynamic_strings)
|
|
|
|
|
printf (_(" %#06x: Parent %d: %s\n"),
|
1998-06-30 00:03:05 +00:00
|
|
|
|
isum, j, dynamic_strings + aux.vda_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
else
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_(" %#06x: Parent %d, name index: %ld\n"),
|
|
|
|
|
isum, j, aux.vda_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
idx += ent.vd_next;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
free (edefs);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SHT_GNU_verneed:
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_External_Verneed * eneed;
|
|
|
|
|
unsigned int idx;
|
|
|
|
|
unsigned int cnt;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
found = 1;
|
|
|
|
|
|
|
|
|
|
printf (_("\nVersion needs section '%s' contains %d entries:\n"),
|
|
|
|
|
SECTION_NAME (section), section->sh_info);
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf
|
|
|
|
|
(_(" Addr: %#08x Offset: %#08x Link to section: %d (%s)\n"),
|
|
|
|
|
section->sh_addr, section->sh_offset, section->sh_link,
|
|
|
|
|
SECTION_NAME (section_headers + section->sh_link));
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (section->sh_offset, section->sh_size,
|
1998-06-30 00:03:05 +00:00
|
|
|
|
eneed, Elf_External_Verneed *,
|
1998-06-23 18:12:44 +00:00
|
|
|
|
"version need section");
|
|
|
|
|
|
|
|
|
|
for (idx = cnt = 0; cnt < section->sh_info; ++cnt)
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_External_Verneed * entry;
|
|
|
|
|
Elf_Internal_Verneed ent;
|
|
|
|
|
int j;
|
|
|
|
|
int isum;
|
|
|
|
|
char * vstart;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
vstart = ((char *) eneed) + idx;
|
|
|
|
|
|
|
|
|
|
entry = (Elf_External_Verneed *) vstart;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ent.vn_version = BYTE_GET (entry->vn_version);
|
|
|
|
|
ent.vn_cnt = BYTE_GET (entry->vn_cnt);
|
|
|
|
|
ent.vn_file = BYTE_GET (entry->vn_file);
|
|
|
|
|
ent.vn_aux = BYTE_GET (entry->vn_aux);
|
|
|
|
|
ent.vn_next = BYTE_GET (entry->vn_next);
|
|
|
|
|
|
|
|
|
|
printf (_(" %#06x: Version: %d"), idx, ent.vn_version);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (dynamic_strings)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_(" File: %s"), dynamic_strings + ent.vn_file);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
else
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_(" File: %lx"), ent.vn_file);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_(" Cnt: %d\n"), ent.vn_cnt);
|
|
|
|
|
|
|
|
|
|
vstart += ent.vn_aux;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
for (j = 0, isum = idx + ent.vn_aux; j < ent.vn_cnt; ++j)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_External_Vernaux * eaux;
|
|
|
|
|
Elf_Internal_Vernaux aux;
|
|
|
|
|
|
|
|
|
|
eaux = (Elf_External_Vernaux *) vstart;
|
|
|
|
|
|
|
|
|
|
aux.vna_hash = BYTE_GET (eaux->vna_hash);
|
|
|
|
|
aux.vna_flags = BYTE_GET (eaux->vna_flags);
|
|
|
|
|
aux.vna_other = BYTE_GET (eaux->vna_other);
|
|
|
|
|
aux.vna_name = BYTE_GET (eaux->vna_name);
|
|
|
|
|
aux.vna_next = BYTE_GET (eaux->vna_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (dynamic_strings)
|
|
|
|
|
printf (_(" %#06x: Name: %s"),
|
1998-06-30 00:03:05 +00:00
|
|
|
|
isum, dynamic_strings + aux.vna_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
else
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (_(" %#06x: Name index: %lx"),
|
|
|
|
|
isum, aux.vna_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
printf (_(" Flags: %s Version: %d\n"),
|
1998-06-30 00:03:05 +00:00
|
|
|
|
get_ver_flags (aux.vna_flags), aux.vna_other);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
isum += aux.vna_next;
|
|
|
|
|
vstart += aux.vna_next;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
idx += ent.vn_next;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
free (eneed);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SHT_GNU_versym:
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf32_Internal_Shdr * link_section;
|
|
|
|
|
int total;
|
|
|
|
|
int cnt;
|
|
|
|
|
unsigned char * edata;
|
|
|
|
|
unsigned short * data;
|
|
|
|
|
char * strtab;
|
|
|
|
|
Elf_Internal_Sym * symbols;
|
|
|
|
|
Elf32_Internal_Shdr * string_sec;
|
|
|
|
|
|
|
|
|
|
link_section = section_headers + section->sh_link;
|
|
|
|
|
total = section->sh_size / section->sh_entsize;
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
found = 1;
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
symbols = get_elf_symbols
|
|
|
|
|
(file, link_section->sh_offset,
|
|
|
|
|
link_section->sh_size / link_section->sh_entsize);
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
string_sec = section_headers + link_section->sh_link;
|
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (string_sec->sh_offset, string_sec->sh_size,
|
|
|
|
|
strtab, char *, "version string table");
|
|
|
|
|
|
|
|
|
|
printf (_("\nVersion symbols section '%s' contains %d entries:\n"),
|
|
|
|
|
SECTION_NAME (section), total);
|
|
|
|
|
|
|
|
|
|
printf (_(" Addr: %#08x Offset: %#08x Link: %x (%s)\n"),
|
|
|
|
|
section->sh_addr, section->sh_offset, section->sh_link,
|
|
|
|
|
SECTION_NAME (link_section));
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA_ALLOC (version_info [DT_VERSIONTAGIDX (DT_VERSYM)]
|
|
|
|
|
- loadaddr,
|
|
|
|
|
total * sizeof (short), edata,
|
|
|
|
|
char *, "version symbol data");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
data = (unsigned short *) malloc (total * sizeof (short));
|
|
|
|
|
|
|
|
|
|
for (cnt = total; cnt --;)
|
|
|
|
|
data [cnt] = byte_get (edata + cnt * sizeof (short), sizeof (short));
|
|
|
|
|
|
|
|
|
|
free (edata);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
for (cnt = 0; cnt < total; cnt += 4)
|
|
|
|
|
{
|
|
|
|
|
int j, nn;
|
|
|
|
|
|
|
|
|
|
printf (" %03x:", cnt);
|
|
|
|
|
|
|
|
|
|
for (j = 0; (j < 4) && (cnt + j) < total; ++j)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
switch (data [cnt + j])
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
printf (" 0 (*local*) ");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
printf (" 1 (*global*) ");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
1998-06-30 00:03:05 +00:00
|
|
|
|
nn = printf ("%4x%c", data [cnt + j] & 0x7fff,
|
|
|
|
|
data [cnt + j] & 0x8000 ? 'h' : ' ');
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (symbols [cnt + j].st_shndx < SHN_LORESERVE
|
|
|
|
|
&& section_headers[symbols [cnt + j].st_shndx].sh_type
|
|
|
|
|
== SHT_NOBITS)
|
|
|
|
|
{
|
|
|
|
|
/* We must test both. */
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_Internal_Verneed ivn;
|
|
|
|
|
unsigned long offset;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
offset = version_info [DT_VERSIONTAGIDX (DT_VERNEED)]
|
|
|
|
|
- loadaddr;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_External_Verneed evn;
|
|
|
|
|
Elf_External_Vernaux evna;
|
|
|
|
|
Elf_Internal_Vernaux ivna;
|
|
|
|
|
unsigned long vna_off;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA (offset, evn, "version need");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivn.vn_aux = BYTE_GET (evn.vn_aux);
|
|
|
|
|
ivn.vn_next = BYTE_GET (evn.vn_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
vna_off = offset + ivn.vn_aux;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA (vna_off, evna,
|
1998-06-23 18:12:44 +00:00
|
|
|
|
"version need aux (1)");
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivna.vna_next = BYTE_GET (evna.vna_next);
|
|
|
|
|
ivna.vna_other = BYTE_GET (evna.vna_other);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
vna_off += ivna.vna_next;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
while (ivna.vna_other != data [cnt + j]
|
|
|
|
|
&& ivna.vna_next != 0);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (ivna.vna_other == data [cnt + j])
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivna.vna_name = BYTE_GET (evna.vna_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
nn += printf ("(%11.11s)",
|
1998-06-30 00:03:05 +00:00
|
|
|
|
strtab + ivna.vna_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
else if (ivn.vn_next == 0)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (data [cnt + j] != 0x8001)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_Internal_Verdef ivd;
|
|
|
|
|
Elf_External_Verdef evd;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
offset = version_info
|
|
|
|
|
[DT_VERSIONTAGIDX (DT_VERDEF)]
|
|
|
|
|
- loadaddr;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA (offset, evd,
|
1998-06-23 18:12:44 +00:00
|
|
|
|
"version definition");
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivd.vd_next = BYTE_GET (evd.vd_next);
|
|
|
|
|
ivd.vd_ndx = BYTE_GET (evd.vd_ndx);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
offset += ivd.vd_next;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
while (ivd.vd_ndx
|
|
|
|
|
!= (data [cnt + j] & 0x7fff)
|
|
|
|
|
&& ivd.vd_next != 0);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (ivd.vd_ndx
|
|
|
|
|
== (data [cnt + j] & 0x7fff))
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_External_Verdaux evda;
|
|
|
|
|
Elf_Internal_Verdaux ivda;
|
|
|
|
|
|
|
|
|
|
ivd.vd_aux = BYTE_GET (evd.vd_aux);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA (offset + ivd.vd_aux, evda,
|
1998-06-23 18:12:44 +00:00
|
|
|
|
"version definition aux");
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivda.vda_name =
|
|
|
|
|
BYTE_GET (evda.vda_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
nn +=
|
|
|
|
|
printf ("(%11.11s)",
|
|
|
|
|
strtab + ivda.vda_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
1998-06-30 00:03:05 +00:00
|
|
|
|
offset += ivn.vn_next;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
while (ivn.vn_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
else if (symbols [cnt + j].st_shndx == SHN_UNDEF)
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_Internal_Verneed ivn;
|
|
|
|
|
unsigned long offset;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
offset = version_info [DT_VERSIONTAGIDX (DT_VERNEED)]
|
|
|
|
|
- loadaddr;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_Internal_Vernaux ivna;
|
|
|
|
|
Elf_External_Verneed evn;
|
|
|
|
|
Elf_External_Vernaux evna;
|
|
|
|
|
unsigned long a_off;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA (offset, evn, "version need");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivn.vn_aux = BYTE_GET (evn.vn_aux);
|
|
|
|
|
ivn.vn_next = BYTE_GET (evn.vn_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
a_off = offset + ivn.vn_aux;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA (a_off, evna,
|
|
|
|
|
"version need aux (2)");
|
|
|
|
|
|
|
|
|
|
ivna.vna_next = BYTE_GET (evna.vna_next);
|
|
|
|
|
ivna.vna_other = BYTE_GET (evna.vna_other);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
a_off += ivna.vna_next;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
while (ivna.vna_other != data [cnt + j]
|
|
|
|
|
&& ivna.vna_next != 0);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (ivna.vna_other == data [cnt + j])
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivna.vna_name = BYTE_GET (evna.vna_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
nn += printf ("(%11.11s)",
|
1998-06-30 00:03:05 +00:00
|
|
|
|
strtab + ivna.vna_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
offset += ivn.vn_next;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
while (ivn.vn_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
else if (data [cnt + j] != 0x8001)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_Internal_Verdef ivd;
|
|
|
|
|
Elf_External_Verdef evd;
|
|
|
|
|
unsigned long offset;
|
|
|
|
|
|
|
|
|
|
offset = version_info
|
|
|
|
|
[DT_VERSIONTAGIDX (DT_VERDEF)] - loadaddr;
|
|
|
|
|
|
|
|
|
|
do
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA (offset, evd, "version def");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivd.vd_next = BYTE_GET (evd.vd_next);
|
|
|
|
|
ivd.vd_ndx = BYTE_GET (evd.vd_ndx);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
offset += ivd.vd_next;
|
|
|
|
|
}
|
|
|
|
|
while (ivd.vd_ndx != (data [cnt + j] & 0x7fff)
|
|
|
|
|
&& ivd.vd_next != 0);
|
|
|
|
|
|
|
|
|
|
if (ivd.vd_ndx == (data [cnt + j] & 0x7fff))
|
|
|
|
|
{
|
|
|
|
|
Elf_External_Verdaux evda;
|
|
|
|
|
Elf_Internal_Verdaux ivda;
|
|
|
|
|
|
|
|
|
|
ivd.vd_aux = BYTE_GET (evd.vd_aux);
|
|
|
|
|
|
|
|
|
|
GET_DATA (offset - ivd.vd_next + ivd.vd_aux,
|
|
|
|
|
evda, "version def aux");
|
|
|
|
|
|
|
|
|
|
ivda.vda_name = BYTE_GET (evda.vda_name);
|
|
|
|
|
|
|
|
|
|
nn += printf ("(%11.11s)",
|
|
|
|
|
strtab + ivda.vda_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nn < 18)
|
|
|
|
|
printf ("%*c", 18 - nn, ' ');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
putchar ('\n');
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
free (data);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
free (strtab);
|
|
|
|
|
free (symbols);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
1998-06-29 07:40:02 +00:00
|
|
|
|
break;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (! found)
|
|
|
|
|
printf (_("\nNo version information found in this file.\n"));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_symbol_binding (binding)
|
|
|
|
|
unsigned int binding;
|
|
|
|
|
{
|
|
|
|
|
static char buff [32];
|
|
|
|
|
|
|
|
|
|
switch (binding)
|
|
|
|
|
{
|
|
|
|
|
case STB_LOCAL: return _("LOCAL");
|
|
|
|
|
case STB_GLOBAL: return _("GLOBAL");
|
|
|
|
|
case STB_WEAK: return _("WEAK");
|
|
|
|
|
default:
|
|
|
|
|
if (binding >= STB_LOPROC && binding <= STB_HIPROC)
|
|
|
|
|
sprintf (buff, _("<processor specific>: %d"), binding);
|
|
|
|
|
else
|
|
|
|
|
sprintf (buff, _("<unknown>: %d"), binding);
|
|
|
|
|
return buff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_symbol_type (type)
|
|
|
|
|
unsigned int type;
|
|
|
|
|
{
|
|
|
|
|
static char buff [32];
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case STT_NOTYPE: return _("NOTYPE");
|
|
|
|
|
case STT_OBJECT: return _("OBJECT");
|
|
|
|
|
case STT_FUNC: return _("FUNC");
|
|
|
|
|
case STT_SECTION: return _("SECTION");
|
|
|
|
|
case STT_FILE: return _("FILE");
|
|
|
|
|
default:
|
|
|
|
|
if (type >= STT_LOPROC && type <= STT_HIPROC)
|
|
|
|
|
sprintf (buff, _("<processor specific>: %d"), type);
|
|
|
|
|
else
|
|
|
|
|
sprintf (buff, _("<unknown>: %d"), type);
|
|
|
|
|
return buff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
get_symbol_index_type (type)
|
|
|
|
|
unsigned short type;
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case SHN_UNDEF: return "UND";
|
|
|
|
|
case SHN_ABS: return "ABS";
|
|
|
|
|
case SHN_COMMON: return "COM";
|
|
|
|
|
default:
|
|
|
|
|
if (type >= SHN_LOPROC && type <= SHN_HIPROC)
|
|
|
|
|
return "PRC";
|
|
|
|
|
else if (type >= SHN_LORESERVE && type <= SHN_HIRESERVE)
|
|
|
|
|
return "RSV";
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
static char buff [32];
|
|
|
|
|
|
|
|
|
|
sprintf (buff, "%3d", type);
|
|
|
|
|
return buff;
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int *
|
|
|
|
|
get_dynamic_data (file, number)
|
|
|
|
|
FILE * file;
|
|
|
|
|
unsigned int number;
|
|
|
|
|
{
|
|
|
|
|
char * e_data;
|
|
|
|
|
int * i_data;
|
|
|
|
|
|
|
|
|
|
e_data = (char *) malloc (number * 4);
|
|
|
|
|
|
|
|
|
|
if (e_data == NULL)
|
|
|
|
|
{
|
|
|
|
|
error (_("Out of memory\n"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fread (e_data, 4, number, file) != number)
|
|
|
|
|
{
|
|
|
|
|
error (_("Unable to read in dynamic data\n"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i_data = (int *) malloc (number * sizeof (* i_data));
|
|
|
|
|
|
|
|
|
|
if (i_data == NULL)
|
|
|
|
|
{
|
|
|
|
|
error (_("Out of memory\n"));
|
|
|
|
|
free (e_data);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (number--)
|
|
|
|
|
i_data [number] = byte_get (e_data + number * 4, 4);
|
|
|
|
|
|
|
|
|
|
free (e_data);
|
|
|
|
|
|
|
|
|
|
return i_data;
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-11 21:51:56 +00:00
|
|
|
|
/* Dump the symbol table */
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_symbol_table (file)
|
|
|
|
|
FILE * file;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf32_Internal_Shdr * section;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
if (! do_syms)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 1;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (dynamic_info [DT_HASH] && do_using_dynamic && dynamic_strings != NULL)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
char nb [4];
|
|
|
|
|
char nc [4];
|
|
|
|
|
int nbuckets;
|
|
|
|
|
int nchains;
|
|
|
|
|
int * buckets;
|
|
|
|
|
int * chains;
|
|
|
|
|
int hn;
|
|
|
|
|
int si;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (fseek (file, dynamic_info [DT_HASH] - loadaddr, SEEK_SET))
|
|
|
|
|
{
|
|
|
|
|
error (_("Unable to seek to start of dynamic information"));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 0;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (fread (& nb, sizeof (nb), 1, file) != 1)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
|
|
|
|
error (_("Failed to read in number of buckets\n"));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 0;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (fread (& nc, sizeof (nc), 1, file) != 1)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
{
|
|
|
|
|
error (_("Failed to read in number of chains\n"));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 0;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
nbuckets = byte_get (nb, 4);
|
|
|
|
|
nchains = byte_get (nc, 4);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
buckets = get_dynamic_data (file, nbuckets);
|
|
|
|
|
chains = get_dynamic_data (file, nchains);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (buckets == NULL || chains == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (_("\nSymbol table for image:\n"));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
printf (_(" Num Buc: Value Size Type Bind Ot Ndx Name\n"));
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
for (hn = 0; hn < nbuckets; hn++)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (! buckets [hn])
|
1998-06-11 21:51:56 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
for (si = buckets [hn]; si; si = chains [si])
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_Internal_Sym * psym;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
psym = dynamic_symbols + si;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (" %3d %3d: %8lx %5ld %6s %6s %2d ",
|
|
|
|
|
si, hn,
|
|
|
|
|
(unsigned long) psym->st_value,
|
|
|
|
|
(unsigned long) psym->st_size,
|
1998-06-23 18:12:44 +00:00
|
|
|
|
get_symbol_type (ELF_ST_TYPE (psym->st_info)),
|
|
|
|
|
get_symbol_binding (ELF_ST_BIND (psym->st_info)),
|
|
|
|
|
psym->st_other);
|
|
|
|
|
|
|
|
|
|
printf ("%3.3s", get_symbol_index_type (psym->st_shndx));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (" %s\n", dynamic_strings + psym->st_name);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
free (buckets);
|
|
|
|
|
free (chains);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
else if (!do_using_dynamic)
|
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0, section = section_headers;
|
|
|
|
|
i < elf_header.e_shnum;
|
|
|
|
|
i++, section++)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned int si;
|
|
|
|
|
char * strtab;
|
|
|
|
|
Elf_Internal_Sym * symtab;
|
|
|
|
|
Elf_Internal_Sym * psym;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if ( section->sh_type != SHT_SYMTAB
|
|
|
|
|
&& section->sh_type != SHT_DYNSYM)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (_("\nSymbol table '%s' contains %d entries:\n"),
|
|
|
|
|
SECTION_NAME (section),
|
|
|
|
|
section->sh_size / section->sh_entsize);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
printf (_(" Num: Value Size Type Bind Ot Ndx Name\n"));
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
symtab = get_elf_symbols (file, section->sh_offset,
|
|
|
|
|
section->sh_size / section->sh_entsize);
|
|
|
|
|
if (symtab == NULL)
|
|
|
|
|
continue;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
if (section->sh_link == elf_header.e_shstrndx)
|
|
|
|
|
strtab = string_table;
|
|
|
|
|
else
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf32_Internal_Shdr * string_sec;
|
|
|
|
|
|
|
|
|
|
string_sec = section_headers + section->sh_link;
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
GET_DATA_ALLOC (string_sec->sh_offset, string_sec->sh_size,
|
|
|
|
|
strtab, char *, "string table");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (si = 0, psym = symtab;
|
|
|
|
|
si < section->sh_size / section->sh_entsize;
|
|
|
|
|
si ++, psym ++)
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
printf (" %3d: %8lx %5ld %-7s %-6s %2d ",
|
|
|
|
|
si,
|
|
|
|
|
(unsigned long) psym->st_value,
|
|
|
|
|
(unsigned long) psym->st_size,
|
1998-06-23 18:12:44 +00:00
|
|
|
|
get_symbol_type (ELF_ST_TYPE (psym->st_info)),
|
|
|
|
|
get_symbol_binding (ELF_ST_BIND (psym->st_info)),
|
1998-06-11 21:51:56 +00:00
|
|
|
|
psym->st_other);
|
|
|
|
|
|
|
|
|
|
if (psym->st_shndx == 0)
|
|
|
|
|
printf ("UND");
|
|
|
|
|
else if ((psym->st_shndx & 0xffff) == 0xfff1)
|
|
|
|
|
printf ("ABS");
|
|
|
|
|
else if ((psym->st_shndx & 0xffff) == 0xfff2)
|
|
|
|
|
printf ("COM");
|
|
|
|
|
else
|
|
|
|
|
printf ("%3d", psym->st_shndx);
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (" %s", strtab + psym->st_name);
|
|
|
|
|
|
|
|
|
|
if (section->sh_type == SHT_DYNSYM &&
|
|
|
|
|
version_info [DT_VERSIONTAGIDX (DT_VERSYM)] != 0)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
unsigned char data[2];
|
1998-06-23 18:12:44 +00:00
|
|
|
|
unsigned short vers_data;
|
|
|
|
|
unsigned long offset;
|
|
|
|
|
int is_nobits;
|
|
|
|
|
int check_def;
|
|
|
|
|
|
|
|
|
|
offset = version_info [DT_VERSIONTAGIDX (DT_VERSYM)]
|
|
|
|
|
- loadaddr;
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA (offset + si * sizeof (vers_data), data,
|
1998-06-23 18:12:44 +00:00
|
|
|
|
"version data");
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
vers_data = byte_get (data, 2);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
is_nobits = psym->st_shndx < SHN_LORESERVE ?
|
|
|
|
|
(section_headers [psym->st_shndx].sh_type == SHT_NOBITS)
|
|
|
|
|
: 0;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
check_def = (psym->st_shndx != SHN_UNDEF);
|
|
|
|
|
|
|
|
|
|
if ((vers_data & 0x8000) || vers_data > 1)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (is_nobits || ! check_def)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_External_Verneed evn;
|
|
|
|
|
Elf_Internal_Verneed ivn;
|
|
|
|
|
Elf_Internal_Vernaux ivna;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
/* We must test both. */
|
|
|
|
|
offset = version_info
|
|
|
|
|
[DT_VERSIONTAGIDX (DT_VERNEED)] - loadaddr;
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA (offset, evn, "version need");
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivn.vn_aux = BYTE_GET (evn.vn_aux);
|
|
|
|
|
ivn.vn_next = BYTE_GET (evn.vn_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
unsigned long vna_off;
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
vna_off = offset + ivn.vn_aux;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_External_Vernaux evna;
|
|
|
|
|
|
|
|
|
|
GET_DATA (vna_off, evna,
|
1998-06-23 18:12:44 +00:00
|
|
|
|
"version need aux (3)");
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivna.vna_other = BYTE_GET (evna.vna_other);
|
|
|
|
|
ivna.vna_next = BYTE_GET (evna.vna_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
vna_off += ivna.vna_next;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
while (ivna.vna_other != vers_data
|
|
|
|
|
&& ivna.vna_next != 0);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (ivna.vna_other == vers_data)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
break;
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
offset += ivn.vn_next;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
while (ivn.vn_next != 0);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (ivna.vna_other == vers_data)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf ("@%s (%d)",
|
1998-06-30 00:03:05 +00:00
|
|
|
|
strtab + ivna.vna_name, ivna.vna_other);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
else if (! is_nobits)
|
|
|
|
|
error (_("bad dynamic symbol"));
|
|
|
|
|
else
|
|
|
|
|
check_def = 1;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (check_def)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (vers_data != 0x8001)
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_Internal_Verdef ivd;
|
|
|
|
|
Elf_Internal_Verdaux ivda;
|
|
|
|
|
Elf_External_Verdaux evda;
|
|
|
|
|
unsigned long offset;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
offset =
|
|
|
|
|
version_info [DT_VERSIONTAGIDX (DT_VERDEF)]
|
|
|
|
|
- loadaddr;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf_External_Verdef evd;
|
|
|
|
|
|
|
|
|
|
GET_DATA (offset, evd, "version def");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivd.vd_ndx = BYTE_GET (evd.vd_ndx);
|
|
|
|
|
ivd.vd_aux = BYTE_GET (evd.vd_aux);
|
|
|
|
|
ivd.vd_next = BYTE_GET (evd.vd_next);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
offset += ivd.vd_next;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
while (ivd.vd_ndx != (vers_data & 0x7fff)
|
|
|
|
|
&& ivd.vd_next != 0);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
offset -= ivd.vd_next;
|
|
|
|
|
offset += ivd.vd_aux;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
GET_DATA (offset, evda, "version def aux");
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
ivda.vda_name = BYTE_GET (evda.vda_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
if (psym->st_name != ivda.vda_name)
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf ((vers_data & 0x8000)
|
|
|
|
|
? "@%s" : "@@%s",
|
1998-06-30 00:03:05 +00:00
|
|
|
|
strtab + ivda.vda_name);
|
1998-06-23 18:12:44 +00:00
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
putchar ('\n');
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
free (symtab);
|
|
|
|
|
if (strtab != string_table)
|
|
|
|
|
free (strtab);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1998-06-23 18:12:44 +00:00
|
|
|
|
else
|
|
|
|
|
printf
|
|
|
|
|
(_("\nDynamic symbol information is not available for displaying symbols.\n"));
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-06-30 00:03:05 +00:00
|
|
|
|
static int
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_section_contents (file)
|
|
|
|
|
FILE * file;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
Elf32_Internal_Shdr * section;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
unsigned int i;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
|
|
|
|
if (! do_dump)
|
1998-06-30 00:03:05 +00:00
|
|
|
|
return 1;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
for (i = 0, section = section_headers;
|
|
|
|
|
i < elf_header.e_shnum;
|
|
|
|
|
i ++, section ++)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef SUPPORT_DISASSEMBLY
|
|
|
|
|
/* See if we need an assembly dump of this section */
|
|
|
|
|
|
|
|
|
|
if ((i < NUM_DUMP_SECTS) && (dump_sects[i] & DISASS_DUMP))
|
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
printf (_("\nAssembly dump of section %s\n"),
|
|
|
|
|
SECTION_NAME (section));
|
|
|
|
|
|
|
|
|
|
/* XXX -- to be done --- XXX */
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
/* See if we need a hex dump of this section. */
|
|
|
|
|
if ((i < NUM_DUMP_SECTS) && (dump_sects[i] & HEX_DUMP))
|
|
|
|
|
{
|
1998-06-30 00:03:05 +00:00
|
|
|
|
int bytes;
|
|
|
|
|
int addr;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
unsigned char * data;
|
1998-06-30 00:03:05 +00:00
|
|
|
|
char * start;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section));
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
bytes = section->sh_size;
|
|
|
|
|
addr = section->sh_addr;
|
|
|
|
|
|
|
|
|
|
GET_DATA_ALLOC (section->sh_offset, bytes, start, char *,
|
|
|
|
|
"section data");
|
|
|
|
|
|
|
|
|
|
data = start;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
while (bytes)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
int j;
|
|
|
|
|
int k;
|
|
|
|
|
int lbytes;
|
|
|
|
|
|
|
|
|
|
lbytes = (bytes > 16 ? 16 : bytes);
|
|
|
|
|
|
|
|
|
|
printf (" 0x%8.8x ", addr);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
switch (elf_header.e_ident [EI_DATA])
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
case ELFDATA2LSB:
|
|
|
|
|
for (j = 15; j >= 0; j --)
|
|
|
|
|
{
|
|
|
|
|
if (j < lbytes)
|
|
|
|
|
printf ("%2.2x", data [j]);
|
|
|
|
|
else
|
|
|
|
|
printf (" ");
|
|
|
|
|
|
|
|
|
|
if (!(j & 0x3))
|
|
|
|
|
printf (" ");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ELFDATA2MSB:
|
|
|
|
|
for (j = 0; j < 16; j++)
|
|
|
|
|
{
|
|
|
|
|
if (j < lbytes)
|
|
|
|
|
printf ("%2.2x", data [j]);
|
|
|
|
|
else
|
|
|
|
|
printf (" ");
|
|
|
|
|
|
|
|
|
|
if ((j & 3) == 3)
|
|
|
|
|
printf (" ");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < lbytes; j++)
|
|
|
|
|
{
|
|
|
|
|
k = data [j];
|
|
|
|
|
if (k >= ' ' && k < 0x80)
|
|
|
|
|
printf ("%c", k);
|
|
|
|
|
else
|
|
|
|
|
printf (".");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
putchar ('\n');
|
|
|
|
|
|
|
|
|
|
data += lbytes;
|
|
|
|
|
addr += lbytes;
|
|
|
|
|
bytes -= lbytes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (start);
|
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
get_file_header (file)
|
|
|
|
|
FILE * file;
|
|
|
|
|
{
|
|
|
|
|
Elf32_External_Ehdr ehdr;
|
|
|
|
|
|
|
|
|
|
if (fread (& ehdr, sizeof (ehdr), 1, file) != 1)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
memcpy (elf_header.e_ident, ehdr.e_ident, EI_NIDENT);
|
|
|
|
|
|
|
|
|
|
if (elf_header.e_ident [EI_DATA] == ELFDATA2LSB)
|
|
|
|
|
byte_get = byte_get_little_endian;
|
|
|
|
|
else
|
|
|
|
|
byte_get = byte_get_big_endian;
|
|
|
|
|
|
|
|
|
|
elf_header.e_entry = BYTE_GET (ehdr.e_entry);
|
|
|
|
|
elf_header.e_phoff = BYTE_GET (ehdr.e_phoff);
|
|
|
|
|
elf_header.e_shoff = BYTE_GET (ehdr.e_shoff);
|
|
|
|
|
elf_header.e_version = BYTE_GET (ehdr.e_version);
|
|
|
|
|
elf_header.e_flags = BYTE_GET (ehdr.e_flags);
|
|
|
|
|
elf_header.e_type = BYTE_GET (ehdr.e_type);
|
|
|
|
|
elf_header.e_machine = BYTE_GET (ehdr.e_machine);
|
|
|
|
|
elf_header.e_ehsize = BYTE_GET (ehdr.e_ehsize);
|
|
|
|
|
elf_header.e_phentsize = BYTE_GET (ehdr.e_phentsize);
|
|
|
|
|
elf_header.e_phnum = BYTE_GET (ehdr.e_phnum);
|
|
|
|
|
elf_header.e_shentsize = BYTE_GET (ehdr.e_shentsize);
|
|
|
|
|
elf_header.e_shnum = BYTE_GET (ehdr.e_shnum);
|
|
|
|
|
elf_header.e_shstrndx = BYTE_GET (ehdr.e_shstrndx);
|
|
|
|
|
|
|
|
|
|
return 1;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
process_file (file_name)
|
|
|
|
|
char * file_name;
|
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
FILE * file;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
struct stat statbuf;
|
1998-06-23 18:12:44 +00:00
|
|
|
|
unsigned int i;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (stat (file_name, & statbuf) < 0)
|
|
|
|
|
{
|
|
|
|
|
error (_("Cannot stat input file %s.\n"), file_name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
file = fopen (file_name, "rb");
|
|
|
|
|
if (file == NULL)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
|
|
|
|
error (_("Input file %s not found.\n"), file_name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
1998-06-30 00:03:05 +00:00
|
|
|
|
|
|
|
|
|
if (! get_file_header (file))
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
error (_("%s: Failed to read file header\n"), file_name);
|
|
|
|
|
fclose (file);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
/* Initialise per file variables. */
|
|
|
|
|
for (i = NUM_ELEM (version_info); i--;)
|
|
|
|
|
version_info [i] = 0;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
for (i = NUM_ELEM (dynamic_info); i--;)
|
|
|
|
|
dynamic_info [i] = 0;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
|
|
|
|
|
/* Process the file. */
|
1998-06-11 21:51:56 +00:00
|
|
|
|
if (show_name)
|
|
|
|
|
printf (_("\nFile: %s\n"), file_name);
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (! process_file_header ())
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
fclose (file);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_section_headers (file);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_program_headers (file);
|
|
|
|
|
|
|
|
|
|
process_dynamic_segment (file);
|
|
|
|
|
|
|
|
|
|
process_relocs (file);
|
|
|
|
|
|
|
|
|
|
process_symbol_table (file);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_version_sections (file);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
process_section_contents (file);
|
|
|
|
|
|
|
|
|
|
fclose (file);
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (section_headers)
|
|
|
|
|
{
|
|
|
|
|
free (section_headers);
|
|
|
|
|
section_headers = NULL;
|
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (string_table)
|
1998-06-11 21:51:56 +00:00
|
|
|
|
{
|
1998-06-23 18:12:44 +00:00
|
|
|
|
free (string_table);
|
|
|
|
|
string_table = NULL;
|
|
|
|
|
}
|
1998-06-11 21:51:56 +00:00
|
|
|
|
|
1998-06-23 18:12:44 +00:00
|
|
|
|
if (dynamic_strings)
|
|
|
|
|
{
|
|
|
|
|
free (dynamic_strings);
|
|
|
|
|
dynamic_strings = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dynamic_symbols)
|
|
|
|
|
{
|
|
|
|
|
free (dynamic_symbols);
|
|
|
|
|
dynamic_symbols = NULL;
|
1998-06-11 21:51:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef SUPPORT_DISASSEMBLY
|
|
|
|
|
/* Needed by the i386 disassembler. For extra credit, someone could
|
|
|
|
|
fix this so that we insert symbolic addresses here, esp for GOT/PLT
|
|
|
|
|
symbols */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
print_address (unsigned int addr, FILE * outfile)
|
|
|
|
|
{
|
|
|
|
|
fprintf (outfile,"0x%8.8x", addr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Needed by the i386 disassembler. */
|
|
|
|
|
void
|
|
|
|
|
db_task_printsym (unsigned int addr)
|
|
|
|
|
{
|
|
|
|
|
print_address (addr, stderr);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main (argc, argv)
|
|
|
|
|
int argc;
|
|
|
|
|
char ** argv;
|
|
|
|
|
{
|
|
|
|
|
parse_args (argc, argv);
|
|
|
|
|
|
|
|
|
|
if (optind < (argc - 1))
|
|
|
|
|
show_name = 1;
|
|
|
|
|
|
|
|
|
|
while (optind < argc)
|
|
|
|
|
process_file (argv [optind ++]);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|