Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
-#include "getopt.h"
#include "progress.h"
#include "bucomm.h"
-#include <ctype.h>
+#include "getopt.h"
+#include "safe-ctype.h"
#include "dis-asm.h"
#include "libiberty.h"
#include "demangle.h"
FILE *stream;
int status;
{
- fprintf (stream, _("Usage: %s OPTION... FILE...\n"), program_name);
- fprintf (stream, _("Display information from object FILE.\n"));
- fprintf (stream, _("\n At least one of the following switches must be given:\n"));
+ fprintf (stream, _("Usage: %s <option(s)> <file(s)>\n"), program_name);
+ fprintf (stream, _(" Display information from object <file(s)>.\n"));
+ fprintf (stream, _(" At least one of the following switches must be given:\n"));
fprintf (stream, _("\
-a, --archive-headers Display archive header information\n\
-f, --file-headers Display the contents of the overall file header\n\
-T, --dynamic-syms Display the contents of the dynamic symbol table\n\
-r, --reloc Display the relocation entries in the file\n\
-R, --dynamic-reloc Display the dynamic relocation entries in the file\n\
- -V, --version Display this program's version number\n\
+ -v, --version Display this program's version number\n\
-i, --info List object formats and architectures supported\n\
-H, --help Display this information\n\
"));
printf ("%3d %-13s %08lx ", section->index,
bfd_get_section_name (abfd, section),
(unsigned long) bfd_section_size (abfd, section) / opb);
- printf_vma (bfd_get_section_vma (abfd, section));
+ bfd_printf_vma (abfd, bfd_get_section_vma (abfd, section));
printf (" ");
- printf_vma (section->lma);
- printf (" %08lx 2**%u", section->filepos,
+ bfd_printf_vma (abfd, section->lma);
+ printf (" %08lx 2**%u", (unsigned long) section->filepos,
bfd_get_section_alignment (abfd, section));
if (! wide_output)
printf ("\n ");
PF (SEC_HAS_CONTENTS, "CONTENTS");
PF (SEC_ALLOC, "ALLOC");
PF (SEC_CONSTRUCTOR, "CONSTRUCTOR");
- PF (SEC_CONSTRUCTOR_TEXT, "CONSTRUCTOR TEXT");
- PF (SEC_CONSTRUCTOR_DATA, "CONSTRUCTOR DATA");
- PF (SEC_CONSTRUCTOR_BSS, "CONSTRUCTOR BSS");
PF (SEC_LOAD, "LOAD");
PF (SEC_RELOC, "RELOC");
-#ifdef SEC_BALIGN
- PF (SEC_BALIGN, "BALIGN");
-#endif
PF (SEC_READONLY, "READONLY");
PF (SEC_CODE, "CODE");
PF (SEC_DATA, "DATA");
PF (SEC_CLINK, "CLINK");
PF (SEC_SMALL_DATA, "SMALL_DATA");
PF (SEC_SHARED, "SHARED");
+ PF (SEC_ARCH_BIT_0, "ARCH_BIT_0");
+ PF (SEC_THREAD_LOCAL, "THREAD_LOCAL");
if ((section->flags & SEC_LINK_ONCE) != 0)
{
#ifndef BFD64
printf (_("Idx Name Size VMA LMA File off Algn"));
#else
- printf (_("Idx Name Size VMA LMA File off Algn"));
+ /* With BFD64, non-ELF returns -1 and wants always 64 bit addresses. */
+ if (bfd_get_arch_size (abfd) == 32)
+ printf (_("Idx Name Size VMA LMA File off Algn"));
+ else
+ printf (_("Idx Name Size VMA LMA File off Algn"));
#endif
if (wide_output)
/* Filter out (in place) symbols that are useless for disassembly.
COUNT is the number of elements in SYMBOLS.
- Return the number of useful symbols. */
+ Return the number of useful symbols. */
static long
remove_useless_symbols (symbols, count)
/* Sort symbols into value order. */
-static int
+static int
compare_symbols (ap, bp)
const PTR ap;
const PTR bp;
{
char buf[30];
char *p;
+ struct objdump_disasm_info *aux
+ = (struct objdump_disasm_info *) info->application_data;
- sprintf_vma (buf, vma);
+ bfd_sprintf_vma (aux->abfd, buf, vma);
if (! skip_zeroes)
p = buf;
else
long min = 0;
long max = sorted_symcount;
long thisplace;
- unsigned int opb = bfd_octets_per_byte (abfd);
+ unsigned int opb = bfd_octets_per_byte (abfd);
if (sorted_symcount < 1)
return NULL;
/* If the file is relocateable, and the symbol could be from this
section, prefer a symbol from this section over symbols from
others, even if the other symbol's value might be closer.
-
+
Note that this may be wrong for some symbol references if the
sections have overlapping memory ranges, but in that case there's
no way to tell what's desired without looking at the relocation
if (strchr (buf, '\n') != NULL)
++p->line;
}
-}
+}
/* Show the line number, or the source line, in a dissassembly
listing. */
p->next = print_files;
print_files = p;
- if (file_start_context)
- l = 0;
- else
- l = line - SHOW_PRECEDING_CONTEXT_LINES;
+ if (file_start_context)
+ l = 0;
+ else
+ l = line - SHOW_PRECEDING_CONTEXT_LINES;
if (l < 0)
l = 0;
skip_to_line (p, l, false);
/* sprintf to a "stream" */
static int
-#ifdef ANSI_PROTOTYPES
-objdump_sprintf (SFILE *f, const char *format, ...)
-#else
-objdump_sprintf (va_alist)
- va_dcl
-#endif
+objdump_sprintf VPARAMS ((SFILE *f, const char *format, ...))
{
-#ifndef ANSI_PROTOTYPES
- SFILE *f;
- const char *format;
-#endif
char *buf;
- va_list args;
size_t n;
-#ifdef ANSI_PROTOTYPES
- va_start (args, format);
-#else
- va_start (args);
- f = va_arg (args, SFILE *);
- format = va_arg (args, const char *);
-#endif
+ VA_OPEN (args, format);
+ VA_FIXEDARG (args, SFILE *, f);
+ VA_FIXEDARG (args, const char *, format);
vasprintf (&buf, format, args);
- va_end (args);
-
if (buf == NULL)
{
+ va_end (args);
fatal (_("Out of virtual memory"));
}
free (buf);
+ VA_CLOSE (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,
+disassemble_bytes (info, disassemble_fn, insns, data,
+ start_offset, stop_offset, relppp,
relppend)
struct disassemble_info *info;
disassembler_ftype disassemble_fn;
char buf[30];
char *s;
- sprintf_vma (buf, section->vma +
- bfd_section_size (section->owner, section) / opb);
+ bfd_sprintf_vma
+ (aux->abfd, buf,
+ (section->vma
+ + bfd_section_size (section->owner, section) / opb));
s = buf;
while (s[0] == '0' && s[1] == '0' && s[2] == '0' && s[3] == '0'
&& s[4] == '0')
&& (info->insn_info_valid == 0
|| info->branch_delay_insns == 0)
&& (z - addr_offset * opb >= SKIP_ZEROES
- || (z == stop_offset * opb &&
- z - addr_offset * opb < SKIP_ZEROES_AT_END)))
+ || (z == stop_offset * opb &&
+ z - addr_offset * opb < SKIP_ZEROES_AT_END)))
{
printf ("\t...\n");
{
char *s;
- sprintf_vma (buf, section->vma + addr_offset);
+ bfd_sprintf_vma (aux->abfd, buf, section->vma + addr_offset);
for (s = buf + skip_addr_chars; *s == '0'; s++)
*s = ' ';
if (*s == '\0')
for (j = addr_offset * opb; j < addr_offset * opb + octets; ++j)
{
- if (isprint (data[j]))
+ if (ISPRINT (data[j]))
buf[j - addr_offset * opb] = data[j];
else
buf[j - addr_offset * opb] = '.';
putchar ('\n');
j = addr_offset * opb + pb;
- sprintf_vma (buf, section->vma + j / opb);
+ bfd_sprintf_vma (aux->abfd, buf, section->vma + j / opb);
for (s = buf + skip_addr_chars; *s == '0'; s++)
*s = ' ';
if (*s == '\0')
}
if ((section->flags & SEC_RELOC) != 0
-#ifndef DISASSEMBLER_NEEDS_RELOCS
- && dump_reloc_info
+#ifndef DISASSEMBLER_NEEDS_RELOCS
+ && dump_reloc_info
#endif
)
{
disasm_info.mach = bfd_get_mach (abfd);
disasm_info.disassembler_options = disassembler_options;
disasm_info.octets_per_byte = opb;
-
+
if (bfd_big_endian (abfd))
disasm_info.display_endian = disasm_info.endian = BFD_ENDIAN_BIG;
else if (bfd_little_endian (abfd))
continue;
if ((section->flags & SEC_RELOC) != 0
-#ifndef DISASSEMBLER_NEEDS_RELOCS
+#ifndef DISASSEMBLER_NEEDS_RELOCS
&& dump_reloc_info
#endif
- )
+ )
{
long relsize;
asymbol *nextsym;
unsigned long nextstop_offset;
boolean insns;
-
+
if (sym != NULL && bfd_asymbol_value (sym) <= section->vma + addr_offset)
{
int x;
false);
printf (":\n");
}
-
+
if (sym != NULL && bfd_asymbol_value (sym) > section->vma + addr_offset)
nextsym = sym;
else if (sym == NULL)
else
nextsym = sorted_syms[place];
}
-
+
if (sym != NULL && bfd_asymbol_value (sym) > section->vma + addr_offset)
{
nextstop_offset = bfd_asymbol_value (sym) - section->vma;
if (nextstop_offset > stop_offset)
nextstop_offset = stop_offset;
}
-
+
/* If a symbol is explicitly marked as being an object
rather than a function, just dump the bytes without
disassembling them. */
insns = true;
else
insns = false;
-
- disassemble_bytes (&disasm_info, disassemble_fn, insns, data,
- addr_offset, nextstop_offset, &relpp, relppend);
-
+
+ disassemble_bytes (&disasm_info, disassemble_fn, insns, data,
+ addr_offset, nextstop_offset, &relpp, relppend);
+
addr_offset = nextstop_offset;
sym = nextsym;
}
-
+
free (data);
if (relbuf != NULL)
free (relbuf);
exit_status = 1;
return false;
}
-
+
stab_size = bfd_section_size (abfd, stabsect);
stabstr_size = bfd_section_size (abfd, stabstrsect);
stabs = (bfd_byte *) xmalloc (stab_size);
strtab = (char *) xmalloc (stabstr_size);
-
+
if (! bfd_get_section_contents (abfd, stabsect, (PTR) stabs, 0, stab_size))
{
non_fatal (_("Reading %s section of %s failed: %s"),
printf ("\n%-6d ", i);
/* Either print the stab name, or, if unnamed, print its number
- again (makes consistent formatting for tools like awk). */
+ again (makes consistent formatting for tools like awk). */
name = bfd_get_stab_name (type);
if (name != NULL)
printf ("%-6s", name);
else
printf ("%-6d", type);
printf (" %-6d %-6d ", other, desc);
- printf_vma (value);
+ bfd_printf_vma (abfd, value);
printf (" %-6lu", strx);
/* Symbols with type == 0 (N_UNDF) specify the length of the
match or a section followed by a number. */
if (strncmp (stabsect_name, s->name, len) == 0
&& (s->name[len] == '\000'
- || isdigit ((unsigned char) s->name[len])))
+ || ISDIGIT (s->name[len])))
{
if (read_section_stabs (abfd, s->name, strsect_name))
{
PF (D_PAGED, "D_PAGED");
PF (BFD_IS_RELAXABLE, "BFD_IS_RELAXABLE");
printf (_("\nstart address 0x"));
- printf_vma (abfd->start_address);
+ bfd_printf_vma (abfd, abfd->start_address);
printf ("\n");
}
\f
if (stop_offset > bfd_section_size (abfd, section) / opb)
stop_offset = bfd_section_size (abfd, section) / opb;
}
- for (addr_offset = start_offset;
- addr_offset < stop_offset; addr_offset += onaline)
+ for (addr_offset = start_offset;
+ addr_offset < stop_offset; addr_offset += onaline)
{
bfd_size_type j;
- printf (" %04lx ", (unsigned long int)
- (addr_offset + section->vma));
- for (j = addr_offset * opb;
- j < addr_offset * opb + onaline; j++)
+ printf (" %04lx ", (unsigned long int)
+ (addr_offset + section->vma));
+ for (j = addr_offset * opb;
+ j < addr_offset * opb + onaline; j++)
{
if (j < stop_offset * opb)
printf ("%02x", (unsigned) (data[j]));
if (j >= stop_offset * opb)
printf (" ");
else
- printf ("%c", isprint (data[j]) ? data[j] : '.');
+ printf ("%c", ISPRINT (data[j]) ? data[j] : '.');
}
putchar ('\n');
}
if (width == 0)
{
char buf[30];
- sprintf_vma (buf, (bfd_vma) -1);
+ bfd_sprintf_vma (abfd, buf, (bfd_vma) -1);
width = strlen (buf) - 7;
}
printf ("OFFSET %*s TYPE %*s VALUE \n", width, "", 12, "");
}
if (sym_name)
{
- printf_vma (q->address);
+ bfd_printf_vma (abfd, q->address);
if (q->howto->name)
printf (" %-16s ", q->howto->name);
else
{
if (section_name == (CONST char *) NULL)
section_name = "*unknown*";
- printf_vma (q->address);
+ bfd_printf_vma (abfd, q->address);
printf (" %-16s [%s]",
q->howto->name,
section_name);
if (q->addend)
{
printf ("+0x");
- printf_vma (q->addend);
+ bfd_printf_vma (abfd, q->addend);
}
printf ("\n");
}
static void
display_info ()
{
- printf (_("BFD header file version %s\n"), BFD_VERSION);
+ printf (_("BFD header file version %s\n"), BFD_VERSION_STRING);
display_target_list ();
display_target_tables ();
}
+int main PARAMS ((int, char **));
+
int
main (argc, argv)
int argc;
#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
setlocale (LC_MESSAGES, "");
#endif
+#if defined (HAVE_SETLOCALE)
+ setlocale (LC_CTYPE, "");
+#endif
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
bfd_init ();
set_default_bfd_target ();
- while ((c = getopt_long (argc, argv, "pib:m:M:VCdDlfahHrRtTxsSj:wE:zgG",
+ while ((c = getopt_long (argc, argv, "pib:m:M:VvCdDlfaHhrRtTxsSj:wE:zgG",
long_options, (int *) 0))
!= EOF)
{
switch (c)
{
case 0:
- break; /* we've been given a long option */
+ break; /* We've been given a long option. */
case 'm':
machine = optarg;
break;
if (optarg != NULL)
{
enum demangling_styles style;
-
+
style = cplus_demangle_name_to_style (optarg);
- if (style == unknown_demangling)
+ if (style == unknown_demangling)
fatal (_("unknown demangling style `%s'"),
optarg);
-
+
cplus_demangle_set_style (style);
- }
+ }
break;
case 'w':
wide_output = true;
usage (stderr, 1);
}
break;
-
+
case 'f':
dump_file_header = true;
seenflag = true;
case 'H':
usage (stdout, 0);
seenflag = true;
+ case 'v':
case 'V':
show_version = true;
seenflag = true;
break;
-
+
default:
usage (stderr, 1);
}