#ifdef NEED_DECLARATION_FPRINTF
/* This is needed by INIT_DISASSEMBLE_INFO. */
extern int fprintf
- PARAMS ((FILE *, const char *, ...));
+ (FILE *, const char *, ...);
#endif
/* Exit status. */
/* Static declarations. */
static void usage
- PARAMS ((FILE *, int));
+ (FILE *, int);
static void nonfatal
- PARAMS ((const char *));
+ (const char *);
static void display_file
- PARAMS ((char *, char *));
+ (char *, char *);
static void dump_section_header
- PARAMS ((bfd *, asection *, PTR));
+ (bfd *, asection *, void *);
static void dump_headers
- PARAMS ((bfd *));
+ (bfd *);
static void dump_data
- PARAMS ((bfd *));
+ (bfd *);
static void dump_relocs
- PARAMS ((bfd *));
+ (bfd *);
static void dump_dynamic_relocs
- PARAMS ((bfd *));
+ (bfd *);
static void dump_reloc_set
- PARAMS ((bfd *, asection *, arelent **, long));
+ (bfd *, asection *, arelent **, long);
static void dump_symbols
- PARAMS ((bfd *, bfd_boolean));
+ (bfd *, bfd_boolean);
static void dump_bfd_header
- PARAMS ((bfd *));
+ (bfd *);
static void dump_bfd_private_header
- PARAMS ((bfd *));
+ (bfd *);
static void dump_bfd
- PARAMS ((bfd *));
+ (bfd *);
static void display_bfd
- PARAMS ((bfd *));
+ (bfd *);
static void objdump_print_value
- PARAMS ((bfd_vma, struct disassemble_info *, bfd_boolean));
+ (bfd_vma, struct disassemble_info *, bfd_boolean);
static void objdump_print_symname
- PARAMS ((bfd *, struct disassemble_info *, asymbol *));
+ (bfd *, struct disassemble_info *, asymbol *);
static asymbol *find_symbol_for_address
- PARAMS ((bfd *, asection *, bfd_vma, bfd_boolean, long *));
+ (bfd *, asection *, bfd_vma, bfd_boolean, long *);
static void objdump_print_addr_with_sym
- PARAMS ((bfd *, asection *, asymbol *, bfd_vma,
- struct disassemble_info *, bfd_boolean));
+ (bfd *, asection *, asymbol *, bfd_vma,
+ struct disassemble_info *, bfd_boolean);
static void objdump_print_addr
- PARAMS ((bfd_vma, struct disassemble_info *, bfd_boolean));
+ (bfd_vma, struct disassemble_info *, bfd_boolean);
static void objdump_print_address
- PARAMS ((bfd_vma, struct disassemble_info *));
+ (bfd_vma, struct disassemble_info *);
static int objdump_symbol_at_address
- PARAMS ((bfd_vma, struct disassemble_info *));
+ (bfd_vma, struct disassemble_info *);
static void show_line
- PARAMS ((bfd *, asection *, bfd_vma));
+ (bfd *, asection *, bfd_vma);
static void disassemble_bytes
- PARAMS ((struct disassemble_info *, disassembler_ftype, bfd_boolean,
- bfd_byte *, bfd_vma, bfd_vma, arelent ***, arelent **));
+ (struct disassemble_info *, disassembler_ftype, bfd_boolean,
+ bfd_byte *, bfd_vma, bfd_vma, arelent ***, arelent **);
static void disassemble_data
- PARAMS ((bfd *));
+ (bfd *);
static asymbol ** slurp_symtab
- PARAMS ((bfd *));
+ (bfd *);
static asymbol ** slurp_dynamic_symtab
- PARAMS ((bfd *));
+ (bfd *);
static long remove_useless_symbols
- PARAMS ((asymbol **, long));
+ (asymbol **, long);
static int compare_symbols
- PARAMS ((const PTR, const PTR));
+ (const void *, const void *);
static int compare_relocs
- PARAMS ((const PTR, const PTR));
+ (const void *, const void *);
static void dump_stabs
- PARAMS ((bfd *));
+ (bfd *);
static bfd_boolean read_section_stabs
- PARAMS ((bfd *, const char *, const char *));
+ (bfd *, const char *, const char *);
static void print_section_stabs
- PARAMS ((bfd *, const char *, const char *));
+ (bfd *, const char *, const char *);
static void dump_section_stabs
- PARAMS ((bfd *, char *, char *));
+ (bfd *, char *, char *);
\f
static void
-usage (stream, status)
- FILE *stream;
- int status;
+usage (FILE *stream, int status)
{
fprintf (stream, _("Usage: %s <option(s)> <file(s)>\n"), program_name);
fprintf (stream, _(" Display information from object <file(s)>.\n"));
}
/* 150 isn't special; it's just an arbitrary non-ASCII char value. */
-
-#define OPTION_ENDIAN (150)
-#define OPTION_START_ADDRESS (OPTION_ENDIAN + 1)
-#define OPTION_STOP_ADDRESS (OPTION_START_ADDRESS + 1)
-#define OPTION_ADJUST_VMA (OPTION_STOP_ADDRESS + 1)
+enum option_values
+ {
+ OPTION_ENDIAN=150,
+ OPTION_START_ADDRESS,
+ OPTION_STOP_ADDRESS,
+ OPTION_ADJUST_VMA
+ };
static struct option long_options[]=
{
};
\f
static void
-nonfatal (msg)
- const char *msg;
+nonfatal (const char *msg)
{
bfd_nonfatal (msg);
exit_status = 1;
}
\f
static void
-dump_section_header (abfd, section, ignored)
- bfd *abfd ATTRIBUTE_UNUSED;
- asection *section;
- PTR ignored ATTRIBUTE_UNUSED;
+dump_section_header (bfd *abfd ATTRIBUTE_UNUSED, asection *section,
+ void *ignored ATTRIBUTE_UNUSED)
{
char *comma = "";
unsigned int opb = bfd_octets_per_byte (abfd);
}
static void
-dump_headers (abfd)
- bfd *abfd;
+dump_headers (bfd *abfd)
{
printf (_("Sections:\n"));
printf (_(" Pg"));
printf ("\n");
- bfd_map_over_sections (abfd, dump_section_header, (PTR) NULL);
+ bfd_map_over_sections (abfd, dump_section_header, NULL);
}
\f
static asymbol **
-slurp_symtab (abfd)
- bfd *abfd;
+slurp_symtab (bfd *abfd)
{
asymbol **sy = (asymbol **) NULL;
long storage;
/* Read in the dynamic symbols. */
static asymbol **
-slurp_dynamic_symtab (abfd)
- bfd *abfd;
+slurp_dynamic_symtab (bfd *abfd)
{
asymbol **sy = (asymbol **) NULL;
long storage;
Return the number of useful symbols. */
static long
-remove_useless_symbols (symbols, count)
- asymbol **symbols;
- long count;
+remove_useless_symbols (asymbol **symbols, long count)
{
- register asymbol **in_ptr = symbols, **out_ptr = symbols;
+ asymbol **in_ptr = symbols, **out_ptr = symbols;
while (--count >= 0)
{
/* Sort symbols into value order. */
static int
-compare_symbols (ap, bp)
- const PTR ap;
- const PTR bp;
+compare_symbols (const void *ap, const void *bp)
{
- const asymbol *a = *(const asymbol **)ap;
- const asymbol *b = *(const asymbol **)bp;
- const char *an, *bn;
- size_t anl, bnl;
- bfd_boolean af, bf;
- flagword aflags, bflags;
+ const asymbol *a = * (const asymbol **) ap;
+ const asymbol *b = * (const asymbol **) bp;
+ const char *an;
+ const char *bn;
+ size_t anl;
+ size_t bnl;
+ bfd_boolean af;
+ bfd_boolean bf;
+ flagword aflags;
+ flagword bflags;
if (bfd_asymbol_value (a) > bfd_asymbol_value (b))
return 1;
/* Sort relocs into address order. */
static int
-compare_relocs (ap, bp)
- const PTR ap;
- const PTR bp;
+compare_relocs (const void *ap, const void *bp)
{
- const arelent *a = *(const arelent **)ap;
- const arelent *b = *(const arelent **)bp;
+ const arelent *a = * (const arelent **) ap;
+ const arelent *b = * (const arelent **) bp;
if (a->address > b->address)
return 1;
/* Print VMA to STREAM. If SKIP_ZEROES is TRUE, omit leading zeroes. */
static void
-objdump_print_value (vma, info, skip_zeroes)
- bfd_vma vma;
- struct disassemble_info *info;
- bfd_boolean skip_zeroes;
+objdump_print_value (bfd_vma vma, struct disassemble_info *info,
+ bfd_boolean skip_zeroes)
{
char buf[30];
char *p;
/* Print the name of a symbol. */
static void
-objdump_print_symname (abfd, info, sym)
- bfd *abfd;
- struct disassemble_info *info;
- asymbol *sym;
+objdump_print_symname (bfd *abfd, struct disassemble_info *info,
+ asymbol *sym)
{
char *alloc;
const char *name;
then *PLACE is set to the index of the symbol in sorted_syms. */
static asymbol *
-find_symbol_for_address (abfd, sec, vma, require_sec, place)
- bfd *abfd;
- asection *sec;
- bfd_vma vma;
- bfd_boolean require_sec;
- long *place;
+find_symbol_for_address (bfd *abfd, asection *sec, bfd_vma vma,
+ bfd_boolean require_sec, long *place)
{
/* @@ Would it speed things up to cache the last two symbols returned,
and maybe their address ranges? For many processors, only one memory
/* Print an address to INFO symbolically. */
static void
-objdump_print_addr_with_sym (abfd, sec, sym, vma, info, skip_zeroes)
- bfd *abfd;
- asection *sec;
- asymbol *sym;
- bfd_vma vma;
- struct disassemble_info *info;
- bfd_boolean skip_zeroes;
+objdump_print_addr_with_sym (bfd *abfd, asection *sec, asymbol *sym,
+ bfd_vma vma, struct disassemble_info *info,
+ bfd_boolean skip_zeroes)
{
objdump_print_value (vma, info, skip_zeroes);
TRUE, don't output leading zeroes. */
static void
-objdump_print_addr (vma, info, skip_zeroes)
- bfd_vma vma;
- struct disassemble_info *info;
- bfd_boolean skip_zeroes;
+objdump_print_addr (bfd_vma vma, struct disassemble_info *info,
+ bfd_boolean skip_zeroes)
{
struct objdump_disasm_info *aux;
asymbol *sym;
routine. */
static void
-objdump_print_address (vma, info)
- bfd_vma vma;
- struct disassemble_info *info;
+objdump_print_address (bfd_vma vma, struct disassemble_info *info)
{
objdump_print_addr (vma, info, ! prefix_addresses);
}
/* Determine of the given address has a symbol associated with it. */
static int
-objdump_symbol_at_address (vma, info)
- bfd_vma vma;
- struct disassemble_info * info;
+objdump_symbol_at_address (bfd_vma vma, struct disassemble_info * info)
{
struct objdump_disasm_info * aux;
asymbol * sym;
/* Skip ahead to a given line in a file, optionally printing each
line. */
-static void skip_to_line
- PARAMS ((struct print_file_list *, unsigned int, bfd_boolean));
-
static void
-skip_to_line (p, line, show)
- struct print_file_list *p;
- unsigned int line;
- bfd_boolean show;
+skip_to_line (struct print_file_list *p, unsigned int line,
+ bfd_boolean show)
{
while (p->line < line)
{
listing. */
static void
-show_line (abfd, section, addr_offset)
- bfd *abfd;
- asection *section;
- bfd_vma addr_offset;
+show_line (bfd *abfd, asection *section, bfd_vma addr_offset)
{
const char *filename;
const char *functionname;
char *current;
} SFILE;
-/* sprintf to a "stream" */
+/* sprintf to a "stream". */
static int
-objdump_sprintf VPARAMS ((SFILE *f, const char *format, ...))
+objdump_sprintf (SFILE *f, const char *format, ...)
{
char *buf;
size_t n;
+ va_list args;
- VA_OPEN (args, format);
- VA_FIXEDARG (args, SFILE *, f);
- VA_FIXEDARG (args, const char *, format);
+ va_start (args, format);
vasprintf (&buf, format, args);
free (buf);
- VA_CLOSE (args);
+ va_end (args);
return n;
}
/* Disassemble some data in memory between given values. */
static void
-disassemble_bytes (info, disassemble_fn, insns, data,
- start_offset, stop_offset, relppp,
- relppend)
- struct disassemble_info *info;
- disassembler_ftype disassemble_fn;
- bfd_boolean insns;
- bfd_byte *data;
- bfd_vma start_offset;
- bfd_vma stop_offset;
- arelent ***relppp;
- arelent **relppend;
+disassemble_bytes (struct disassemble_info * info,
+ disassembler_ftype disassemble_fn,
+ bfd_boolean insns,
+ bfd_byte * data,
+ bfd_vma start_offset,
+ bfd_vma stop_offset,
+ arelent *** relppp,
+ arelent ** relppend)
{
struct objdump_disasm_info *aux;
asection *section;
/* Disassemble the contents of an object file. */
static void
-disassemble_data (abfd)
- bfd *abfd;
+disassemble_data (bfd *abfd)
{
unsigned long addr_offset;
disassembler_ftype disassemble_fn;
INIT_DISASSEMBLE_INFO (disasm_info, stdout, fprintf);
- disasm_info.application_data = (PTR) &aux;
+ disasm_info.application_data = (void *) &aux;
aux.abfd = abfd;
aux.require_sec = FALSE;
disasm_info.print_address_func = objdump_print_address;
asymbol *sym = NULL;
long place = 0;
- /* Sections that do not contain machine code are not normally disassembled. */
+ /* Sections that do not contain machine
+ code are not normally disassembled. */
if (! disassemble_all
&& only == NULL
&& (section->flags & SEC_CODE) == 0)
for (x = place;
(x < sorted_symcount
- && bfd_asymbol_value (sorted_syms[x]) <= section->vma + addr_offset);
+ && bfd_asymbol_value (sorted_syms[x])
+ <= section->vma + addr_offset);
++x)
continue;
(* disasm_info.fprintf_func) (disasm_info.stream, ":\n");
}
- if (sym != NULL && bfd_asymbol_value (sym) > section->vma + addr_offset)
+ if (sym != NULL
+ && bfd_asymbol_value (sym) > section->vma + addr_offset)
nextsym = sym;
else if (sym == NULL)
nextsym = NULL;
uses Sun stabs encoding. */
static void
-dump_stabs (abfd)
- bfd *abfd;
+dump_stabs (bfd *abfd)
{
dump_section_stabs (abfd, ".stab", ".stabstr");
dump_section_stabs (abfd, ".stab.excl", ".stab.exclstr");
Otherwise return FALSE. */
static bfd_boolean
-read_section_stabs (abfd, stabsect_name, strsect_name)
- bfd *abfd;
- const char *stabsect_name;
- const char *strsect_name;
+read_section_stabs (bfd *abfd, const char *stabsect_name,
+ const char *strsect_name)
{
asection *stabsect, *stabstrsect;
stabs = (bfd_byte *) xmalloc (stab_size);
strtab = (char *) xmalloc (stabstr_size);
- if (! bfd_get_section_contents (abfd, stabsect, (PTR) stabs, 0, stab_size))
+ if (! bfd_get_section_contents (abfd, stabsect, (void *) stabs, 0, stab_size))
{
non_fatal (_("Reading %s section of %s failed: %s"),
stabsect_name, bfd_get_filename (abfd),
return FALSE;
}
- if (! bfd_get_section_contents (abfd, stabstrsect, (PTR) strtab, 0,
+ if (! bfd_get_section_contents (abfd, stabstrsect, (void *) strtab, 0,
stabstr_size))
{
non_fatal (_("Reading %s section of %s failed: %s\n"),
4 byte stab value
FIXME: This will have to change for a 64 bit object format. */
-#define STRDXOFF (0)
-#define TYPEOFF (4)
-#define OTHEROFF (5)
-#define DESCOFF (6)
-#define VALOFF (8)
+#define STRDXOFF (0)
+#define TYPEOFF (4)
+#define OTHEROFF (5)
+#define DESCOFF (6)
+#define VALOFF (8)
#define STABSIZE (12)
/* Print ABFD's stabs section STABSECT_NAME (in `stabs'),
using string table section STRSECT_NAME (in `strtab'). */
static void
-print_section_stabs (abfd, stabsect_name, strsect_name)
- bfd *abfd;
- const char *stabsect_name;
- const char *strsect_name ATTRIBUTE_UNUSED;
+print_section_stabs (bfd *abfd, const char *stabsect_name,
+ const char *strsect_name ATTRIBUTE_UNUSED)
{
int i;
- unsigned file_string_table_offset = 0, next_file_string_table_offset = 0;
+ unsigned file_string_table_offset = 0;
+ unsigned next_file_string_table_offset = 0;
bfd_byte *stabp, *stabs_end;
stabp = stabs;
}
static void
-dump_section_stabs (abfd, stabsect_name, strsect_name)
- bfd *abfd;
- char *stabsect_name;
- char *strsect_name;
+dump_section_stabs (bfd *abfd, char *stabsect_name, char *strsect_name)
{
asection *s;
\f
static void
-dump_bfd_header (abfd)
- bfd *abfd;
+dump_bfd_header (bfd *abfd)
{
char *comma = "";
\f
static void
-dump_bfd_private_header (abfd)
-bfd *abfd;
+dump_bfd_private_header (bfd *abfd)
{
bfd_print_private_bfd_data (abfd, stdout);
}
/* Dump selected contents of ABFD. */
static void
-dump_bfd (abfd)
- bfd *abfd;
+dump_bfd (bfd *abfd)
{
/* If we are adjusting section VMA's, change them all now. Changing
the BFD information is a hack. However, we must do it, or
disassemble_data (abfd);
if (dump_debugging)
{
- PTR dhandle;
+ void *dhandle;
dhandle = read_debugging_info (abfd, syms, symcount);
if (dhandle != NULL)
}
static void
-display_bfd (abfd)
- bfd *abfd;
+display_bfd (bfd *abfd)
{
char **matching;
}
static void
-display_file (filename, target)
- char *filename;
- char *target;
+display_file (char *filename, char *target)
{
bfd *file, *arfile = (bfd *) NULL;
/* Actually display the various requested regions. */
static void
-dump_data (abfd)
- bfd *abfd;
+dump_data (bfd *abfd)
{
asection *section;
bfd_byte *data = 0;
if (bfd_section_size (abfd, section) == 0)
continue;
- data = (bfd_byte *) xmalloc ((size_t) bfd_section_size (abfd, section));
+ data = (bfd_byte *) xmalloc ((size_t) bfd_section_size
+ (abfd, section));
datasize = bfd_section_size (abfd, section);
- bfd_get_section_contents (abfd, section, (PTR) data, 0, bfd_section_size (abfd, section));
+ bfd_get_section_contents (abfd, section, (void *) data, 0,
+ bfd_section_size (abfd, section));
if (start_address == (bfd_vma) -1
|| start_address < section->vma)
/* Should perhaps share code and display with nm? */
static void
-dump_symbols (abfd, dynamic)
- bfd *abfd ATTRIBUTE_UNUSED;
- bfd_boolean dynamic;
+dump_symbols (bfd *abfd ATTRIBUTE_UNUSED, bfd_boolean dynamic)
{
asymbol **current;
long max;
}
static void
-dump_relocs (abfd)
- bfd *abfd;
+dump_relocs (bfd *abfd)
{
arelent **relpp;
long relcount;
}
static void
-dump_dynamic_relocs (abfd)
- bfd *abfd;
+dump_dynamic_relocs (bfd *abfd)
{
long relsize;
arelent **relpp;
}
static void
-dump_reloc_set (abfd, sec, relpp, relcount)
- bfd *abfd;
- asection *sec;
- arelent **relpp;
- long relcount;
+dump_reloc_set (bfd *abfd, asection *sec, arelent **relpp, long relcount)
{
arelent **p;
char *last_filename, *last_functionname;
}
}
\f
-int main PARAMS ((int, char **));
-
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
int c;
char *target = default_target;
case 'M':
if (disassembler_options)
/* Ignore potential memory leak for now. */
- disassembler_options = concat (disassembler_options, ",", optarg, NULL);
+ disassembler_options = concat (disassembler_options, ",",
+ optarg, NULL);
else
disassembler_options = optarg;
break;