* objdump.c (objdump_print_value): Add skip_zeroes parameter.
Change all callers. (objdump_print_addr_with_sym): Likewise. Call objdump_print_value to print address. (objdump_print_addr): New static function. (objdump_print_address): Just call objdump_print_addr. (disassemble_bytes): Print real address, not function offset. Skip a certain number of leading zeroes. * objdump.c (disassemble_zeroes): New static variable. (usage): Mention --disassemble-zeroes. (long_options): Add "disassemble-zeroes". (disassemble_bytes): Check disassemble_zeroes. Changes requested by LSI.
This commit is contained in:
parent
7e2b3363f1
commit
51b8c41677
@ -1,3 +1,19 @@
|
|||||||
|
Wed Jan 29 13:21:21 1997 Ian Lance Taylor <ian@cygnus.com>
|
||||||
|
|
||||||
|
* objdump.c (objdump_print_value): Add skip_zeroes parameter.
|
||||||
|
Change all callers.
|
||||||
|
(objdump_print_addr_with_sym): Likewise. Call objdump_print_value
|
||||||
|
to print address.
|
||||||
|
(objdump_print_addr): New static function.
|
||||||
|
(objdump_print_address): Just call objdump_print_addr.
|
||||||
|
(disassemble_bytes): Print real address, not function offset.
|
||||||
|
Skip a certain number of leading zeroes.
|
||||||
|
|
||||||
|
* objdump.c (disassemble_zeroes): New static variable.
|
||||||
|
(usage): Mention --disassemble-zeroes.
|
||||||
|
(long_options): Add "disassemble-zeroes".
|
||||||
|
(disassemble_bytes): Check disassemble_zeroes.
|
||||||
|
|
||||||
Tue Jan 28 16:47:26 1997 Ian Lance Taylor <ian@cygnus.com>
|
Tue Jan 28 16:47:26 1997 Ian Lance Taylor <ian@cygnus.com>
|
||||||
|
|
||||||
* objdump.c (disassemble_bytes): Don't skip zeroes if the
|
* objdump.c (disassemble_bytes): Don't skip zeroes if the
|
||||||
|
@ -1038,6 +1038,7 @@ Show a summary of the options to @code{objcopy}.
|
|||||||
objdump [ -a | --archive-headers ]
|
objdump [ -a | --archive-headers ]
|
||||||
[ -b @var{bfdname} | --target=@var{bfdname} ] [ --debugging ]
|
[ -b @var{bfdname} | --target=@var{bfdname} ] [ --debugging ]
|
||||||
[ -d | --disassemble ] [ -D | --disassemble-all ]
|
[ -d | --disassemble ] [ -D | --disassemble-all ]
|
||||||
|
[ --disassemble-zeroes ]
|
||||||
[ -EB | -EL | --endian=@{big | little @} ]
|
[ -EB | -EL | --endian=@{big | little @} ]
|
||||||
[ -f | --file-headers ]
|
[ -f | --file-headers ]
|
||||||
[ -h | --section-headers | --headers ] [ -i | --info ]
|
[ -h | --section-headers | --headers ] [ -i | --info ]
|
||||||
@ -1112,6 +1113,15 @@ expected to contain instructions.
|
|||||||
Like @samp{-d}, but disassemble the contents of all sections, not just
|
Like @samp{-d}, but disassemble the contents of all sections, not just
|
||||||
those expected to contain instructions.
|
those expected to contain instructions.
|
||||||
|
|
||||||
|
@item --prefix-addresses
|
||||||
|
When disassembling, print the complete address on each line. This is
|
||||||
|
the older disassembly format.
|
||||||
|
|
||||||
|
@item --disassemble-zeroes
|
||||||
|
Normally the disassembly output will skip blocks of zeroes. This
|
||||||
|
option directs the disassembler to disassemble those blocks, just like
|
||||||
|
any other data.
|
||||||
|
|
||||||
@item -EB
|
@item -EB
|
||||||
@itemx -EL
|
@itemx -EL
|
||||||
@itemx --endian=@{big|little@}
|
@itemx --endian=@{big|little@}
|
||||||
@ -1174,10 +1184,6 @@ can be useful when disasembling object files which do not describe
|
|||||||
architecture information, such as S-records. You can list the available
|
architecture information, such as S-records. You can list the available
|
||||||
architectures with the @samp{-i} option.
|
architectures with the @samp{-i} option.
|
||||||
|
|
||||||
@item --prefix-addresses
|
|
||||||
When disassembling, print the complete address on each line. This is
|
|
||||||
the older disassembly format.
|
|
||||||
|
|
||||||
@item -r
|
@item -r
|
||||||
@itemx --reloc
|
@itemx --reloc
|
||||||
@cindex relocation entries, in object file
|
@cindex relocation entries, in object file
|
||||||
|
@ -24,6 +24,7 @@ objdump \- display information from object files.
|
|||||||
.RB "[\|" \-\-debugging "\|]"
|
.RB "[\|" \-\-debugging "\|]"
|
||||||
.RB "[\|" \-d | \-\-disassemble "\|]"
|
.RB "[\|" \-d | \-\-disassemble "\|]"
|
||||||
.RB "[\|" \-D | \-\-disassemble-all "\|]"
|
.RB "[\|" \-D | \-\-disassemble-all "\|]"
|
||||||
|
.RB "[\|" \-\-disassemble\-zeroes "\|]"
|
||||||
.RB "[\|" \-EB | \-EL | \-\-endian=\c
|
.RB "[\|" \-EB | \-EL | \-\-endian=\c
|
||||||
.I {big|little}\c
|
.I {big|little}\c
|
||||||
\&\|]
|
\&\|]
|
||||||
@ -155,6 +156,17 @@ expected to contain instructions.
|
|||||||
Like \fB\-d\fP, but disassemble the contents of all sections, not just
|
Like \fB\-d\fP, but disassemble the contents of all sections, not just
|
||||||
those expected to contain instructions.
|
those expected to contain instructions.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-\-prefix\-addresses
|
||||||
|
When disassembling, print the complete address on each line. This is
|
||||||
|
the older disassembly format.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-\-disassemble\-zeroes
|
||||||
|
Normally the disassembly output will skip blocks of zeroes. This
|
||||||
|
option directs the disassembler to disassemble those blocks, just like
|
||||||
|
any other data.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-EB
|
.B \-EB
|
||||||
.TP
|
.TP
|
||||||
@ -225,11 +237,6 @@ can be useful when disasembling object files which do not describe
|
|||||||
architecture information, such as S-records. You can list the available
|
architecture information, such as S-records. You can list the available
|
||||||
architectures with the \fB\-i\fP option.
|
architectures with the \fB\-i\fP option.
|
||||||
|
|
||||||
.TP
|
|
||||||
.B \-\-prefix\-addresses
|
|
||||||
When disassembling, print the complete address on each line. This is
|
|
||||||
the older disassembly format.
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-r
|
.B \-r
|
||||||
.TP
|
.TP
|
||||||
|
@ -61,6 +61,7 @@ static int show_raw_insn; /* --show-raw-insn */
|
|||||||
static int dump_stab_section_info; /* --stabs */
|
static int dump_stab_section_info; /* --stabs */
|
||||||
static boolean disassemble; /* -d */
|
static boolean disassemble; /* -d */
|
||||||
static boolean disassemble_all; /* -D */
|
static boolean disassemble_all; /* -D */
|
||||||
|
static int disassemble_zeroes; /* --disassemble-zeroes */
|
||||||
static boolean formats_info; /* -i */
|
static boolean formats_info; /* -i */
|
||||||
static char *only; /* -j secname */
|
static char *only; /* -j secname */
|
||||||
static int wide_output; /* -w */
|
static int wide_output; /* -w */
|
||||||
@ -123,14 +124,17 @@ static void
|
|||||||
display_bfd PARAMS ((bfd *abfd));
|
display_bfd PARAMS ((bfd *abfd));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
objdump_print_value PARAMS ((bfd_vma, struct disassemble_info *));
|
objdump_print_value PARAMS ((bfd_vma, struct disassemble_info *, boolean));
|
||||||
|
|
||||||
static asymbol *
|
static asymbol *
|
||||||
find_symbol_for_address PARAMS ((bfd *, asection *, bfd_vma, boolean, long *));
|
find_symbol_for_address PARAMS ((bfd *, asection *, bfd_vma, boolean, long *));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
objdump_print_addr_with_sym PARAMS ((bfd *, asection *, asymbol *, bfd_vma,
|
objdump_print_addr_with_sym PARAMS ((bfd *, asection *, asymbol *, bfd_vma,
|
||||||
struct disassemble_info *));
|
struct disassemble_info *, boolean));
|
||||||
|
|
||||||
|
static void
|
||||||
|
objdump_print_addr PARAMS ((bfd_vma, struct disassemble_info *, boolean));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
objdump_print_address PARAMS ((bfd_vma, struct disassemble_info *));
|
objdump_print_address PARAMS ((bfd_vma, struct disassemble_info *));
|
||||||
@ -157,7 +161,8 @@ usage (stream, status)
|
|||||||
fprintf (stream, "\
|
fprintf (stream, "\
|
||||||
Usage: %s [-ahifdDprRtTxsSlw] [-b bfdname] [-m machine] [-j section-name]\n\
|
Usage: %s [-ahifdDprRtTxsSlw] [-b bfdname] [-m machine] [-j section-name]\n\
|
||||||
[--archive-headers] [--target=bfdname] [--debugging] [--disassemble]\n\
|
[--archive-headers] [--target=bfdname] [--debugging] [--disassemble]\n\
|
||||||
[--disassemble-all] [--file-headers] [--section-headers] [--headers]\n\
|
[--disassemble-all] [--disassemble-zeroes] [--file-headers]\n\
|
||||||
|
[--section-headers] [--headers]\n\
|
||||||
[--info] [--section=section-name] [--line-numbers] [--source]\n",
|
[--info] [--section=section-name] [--line-numbers] [--source]\n",
|
||||||
program_name);
|
program_name);
|
||||||
fprintf (stream, "\
|
fprintf (stream, "\
|
||||||
@ -189,6 +194,7 @@ static struct option long_options[]=
|
|||||||
{"debugging", no_argument, &dump_debugging, 1},
|
{"debugging", no_argument, &dump_debugging, 1},
|
||||||
{"disassemble", no_argument, NULL, 'd'},
|
{"disassemble", no_argument, NULL, 'd'},
|
||||||
{"disassemble-all", no_argument, NULL, 'D'},
|
{"disassemble-all", no_argument, NULL, 'D'},
|
||||||
|
{"disassemble-zeroes", no_argument, &disassemble_zeroes, 1},
|
||||||
{"dynamic-reloc", no_argument, NULL, 'R'},
|
{"dynamic-reloc", no_argument, NULL, 'R'},
|
||||||
{"dynamic-syms", no_argument, NULL, 'T'},
|
{"dynamic-syms", no_argument, NULL, 'T'},
|
||||||
{"endian", required_argument, NULL, OPTION_ENDIAN},
|
{"endian", required_argument, NULL, OPTION_ENDIAN},
|
||||||
@ -527,21 +533,27 @@ compare_relocs (ap, bp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print VMA to STREAM with no leading zeroes. */
|
/* Print VMA to STREAM. If SKIP_ZEROES is true, omit leading zeroes. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
objdump_print_value (vma, info)
|
objdump_print_value (vma, info, skip_zeroes)
|
||||||
bfd_vma vma;
|
bfd_vma vma;
|
||||||
struct disassemble_info *info;
|
struct disassemble_info *info;
|
||||||
|
boolean skip_zeroes;
|
||||||
{
|
{
|
||||||
char buf[30];
|
char buf[30];
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
sprintf_vma (buf, vma);
|
sprintf_vma (buf, vma);
|
||||||
for (p = buf; *p == '0'; ++p)
|
if (! skip_zeroes)
|
||||||
;
|
p = buf;
|
||||||
if (*p == '\0')
|
else
|
||||||
--p;
|
{
|
||||||
|
for (p = buf; *p == '0'; ++p)
|
||||||
|
;
|
||||||
|
if (*p == '\0')
|
||||||
|
--p;
|
||||||
|
}
|
||||||
(*info->fprintf_func) (info->stream, "%s", p);
|
(*info->fprintf_func) (info->stream, "%s", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,17 +685,15 @@ find_symbol_for_address (abfd, sec, vma, require_sec, place)
|
|||||||
/* Print an address to INFO symbolically. */
|
/* Print an address to INFO symbolically. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
objdump_print_addr_with_sym (abfd, sec, sym, vma, info)
|
objdump_print_addr_with_sym (abfd, sec, sym, vma, info, skip_zeroes)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
asection *sec;
|
asection *sec;
|
||||||
asymbol *sym;
|
asymbol *sym;
|
||||||
bfd_vma vma;
|
bfd_vma vma;
|
||||||
struct disassemble_info *info;
|
struct disassemble_info *info;
|
||||||
|
boolean skip_zeroes;
|
||||||
{
|
{
|
||||||
char buf[30];
|
objdump_print_value (vma, info, skip_zeroes);
|
||||||
|
|
||||||
sprintf_vma (buf, vma);
|
|
||||||
(*info->fprintf_func) (info->stream, "%s", buf);
|
|
||||||
|
|
||||||
if (sym == NULL)
|
if (sym == NULL)
|
||||||
{
|
{
|
||||||
@ -695,12 +705,12 @@ objdump_print_addr_with_sym (abfd, sec, sym, vma, info)
|
|||||||
if (vma < secaddr)
|
if (vma < secaddr)
|
||||||
{
|
{
|
||||||
(*info->fprintf_func) (info->stream, "-");
|
(*info->fprintf_func) (info->stream, "-");
|
||||||
objdump_print_value (secaddr - vma, info);
|
objdump_print_value (secaddr - vma, info, true);
|
||||||
}
|
}
|
||||||
else if (vma > secaddr)
|
else if (vma > secaddr)
|
||||||
{
|
{
|
||||||
(*info->fprintf_func) (info->stream, "+");
|
(*info->fprintf_func) (info->stream, "+");
|
||||||
objdump_print_value (vma - secaddr, info);
|
objdump_print_value (vma - secaddr, info, true);
|
||||||
}
|
}
|
||||||
(*info->fprintf_func) (info->stream, ">");
|
(*info->fprintf_func) (info->stream, ">");
|
||||||
}
|
}
|
||||||
@ -710,40 +720,51 @@ objdump_print_addr_with_sym (abfd, sec, sym, vma, info)
|
|||||||
if (bfd_asymbol_value (sym) > vma)
|
if (bfd_asymbol_value (sym) > vma)
|
||||||
{
|
{
|
||||||
(*info->fprintf_func) (info->stream, "-");
|
(*info->fprintf_func) (info->stream, "-");
|
||||||
objdump_print_value (bfd_asymbol_value (sym) - vma, info);
|
objdump_print_value (bfd_asymbol_value (sym) - vma, info, true);
|
||||||
}
|
}
|
||||||
else if (vma > bfd_asymbol_value (sym))
|
else if (vma > bfd_asymbol_value (sym))
|
||||||
{
|
{
|
||||||
(*info->fprintf_func) (info->stream, "+");
|
(*info->fprintf_func) (info->stream, "+");
|
||||||
objdump_print_value (vma - bfd_asymbol_value (sym), info);
|
objdump_print_value (vma - bfd_asymbol_value (sym), info, true);
|
||||||
}
|
}
|
||||||
(*info->fprintf_func) (info->stream, ">");
|
(*info->fprintf_func) (info->stream, ">");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print VMA symbolically to INFO if possible. */
|
/* Print VMA to INFO, symbolically if possible. If SKIP_ZEROES is
|
||||||
|
true, don't output leading zeroes. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
objdump_print_address (vma, info)
|
objdump_print_addr (vma, info, skip_zeroes)
|
||||||
bfd_vma vma;
|
bfd_vma vma;
|
||||||
struct disassemble_info *info;
|
struct disassemble_info *info;
|
||||||
|
boolean skip_zeroes;
|
||||||
{
|
{
|
||||||
struct objdump_disasm_info *aux;
|
struct objdump_disasm_info *aux;
|
||||||
asymbol *sym;
|
asymbol *sym;
|
||||||
|
|
||||||
if (sorted_symcount < 1)
|
if (sorted_symcount < 1)
|
||||||
{
|
{
|
||||||
char buf[30];
|
objdump_print_value (vma, info, skip_zeroes);
|
||||||
|
|
||||||
sprintf_vma (buf, vma);
|
|
||||||
(*info->fprintf_func) (info->stream, "%s", buf);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
aux = (struct objdump_disasm_info *) info->application_data;
|
aux = (struct objdump_disasm_info *) info->application_data;
|
||||||
sym = find_symbol_for_address (aux->abfd, aux->sec, vma, aux->require_sec,
|
sym = find_symbol_for_address (aux->abfd, aux->sec, vma, aux->require_sec,
|
||||||
(long *) NULL);
|
(long *) NULL);
|
||||||
objdump_print_addr_with_sym (aux->abfd, aux->sec, sym, vma, info);
|
objdump_print_addr_with_sym (aux->abfd, aux->sec, sym, vma, info,
|
||||||
|
skip_zeroes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print VMA to INFO. This function is passed to the disassembler
|
||||||
|
routine. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
objdump_print_address (vma, info)
|
||||||
|
bfd_vma vma;
|
||||||
|
struct disassemble_info *info;
|
||||||
|
{
|
||||||
|
objdump_print_addr (vma, info, ! prefix_addresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hold the last function name and the last line number we displayed
|
/* Hold the last function name and the last line number we displayed
|
||||||
@ -1018,6 +1039,7 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp,
|
|||||||
asection *section;
|
asection *section;
|
||||||
int bytes_per_line;
|
int bytes_per_line;
|
||||||
boolean done_dot;
|
boolean done_dot;
|
||||||
|
int skip_addr_chars;
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
aux = (struct objdump_disasm_info *) info->application_data;
|
aux = (struct objdump_disasm_info *) info->application_data;
|
||||||
@ -1028,6 +1050,27 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp,
|
|||||||
else
|
else
|
||||||
bytes_per_line = 16;
|
bytes_per_line = 16;
|
||||||
|
|
||||||
|
/* Figure out how many characters to skip at the start of an
|
||||||
|
address, to make the disassembly look nicer. We discard leading
|
||||||
|
zeroes in chunks of 4, ensuring that there is always a leading
|
||||||
|
zero remaining. */
|
||||||
|
skip_addr_chars = 0;
|
||||||
|
if (! prefix_addresses)
|
||||||
|
{
|
||||||
|
char buf[30];
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
sprintf_vma (buf,
|
||||||
|
section->vma + bfd_section_size (section->owner, section));
|
||||||
|
s = buf;
|
||||||
|
while (s[0] == '0' && s[1] == '0' && s[2] == '0' && s[3] == '0'
|
||||||
|
&& s[4] == '0')
|
||||||
|
{
|
||||||
|
skip_addr_chars += 4;
|
||||||
|
s += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
info->insn_info_valid = 0;
|
info->insn_info_valid = 0;
|
||||||
|
|
||||||
done_dot = false;
|
done_dot = false;
|
||||||
@ -1043,8 +1086,9 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp,
|
|||||||
for (z = i; z < stop; z++)
|
for (z = i; z < stop; z++)
|
||||||
if (data[z] != 0)
|
if (data[z] != 0)
|
||||||
break;
|
break;
|
||||||
if ((info->insn_info_valid == 0
|
if (! disassemble_zeroes
|
||||||
|| info->branch_delay_insns == 0)
|
&& (info->insn_info_valid == 0
|
||||||
|
|| info->branch_delay_insns == 0)
|
||||||
&& (z - i >= SKIP_ZEROES
|
&& (z - i >= SKIP_ZEROES
|
||||||
|| (z == stop && z - i < SKIP_ZEROES_AT_END)))
|
|| (z == stop && z - i < SKIP_ZEROES_AT_END)))
|
||||||
{
|
{
|
||||||
@ -1071,7 +1115,16 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp,
|
|||||||
show_line (aux->abfd, section, i);
|
show_line (aux->abfd, section, i);
|
||||||
|
|
||||||
if (! prefix_addresses)
|
if (! prefix_addresses)
|
||||||
printf ("%6lx:\t", (unsigned long) (i - start));
|
{
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
sprintf_vma (buf, section->vma + i);
|
||||||
|
for (s = buf + skip_addr_chars; *s == '0'; s++)
|
||||||
|
*s = ' ';
|
||||||
|
if (*s == '\0')
|
||||||
|
*--s = '0';
|
||||||
|
printf ("%s:\t", buf + skip_addr_chars);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
aux->require_sec = true;
|
aux->require_sec = true;
|
||||||
@ -1183,7 +1236,7 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp,
|
|||||||
else
|
else
|
||||||
printf ("\t\t\t");
|
printf ("\t\t\t");
|
||||||
|
|
||||||
objdump_print_value (section->vma + q->address - start, info);
|
objdump_print_value (section->vma + q->address, info, true);
|
||||||
|
|
||||||
printf (": %s\t", q->howto->name);
|
printf (": %s\t", q->howto->name);
|
||||||
|
|
||||||
@ -1209,7 +1262,7 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp,
|
|||||||
if (q->addend)
|
if (q->addend)
|
||||||
{
|
{
|
||||||
printf ("+0x");
|
printf ("+0x");
|
||||||
objdump_print_value (q->addend, info);
|
objdump_print_value (q->addend, info, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
@ -1397,7 +1450,8 @@ disassemble_data (abfd)
|
|||||||
printf ("\n");
|
printf ("\n");
|
||||||
objdump_print_addr_with_sym (abfd, section, sym,
|
objdump_print_addr_with_sym (abfd, section, sym,
|
||||||
section->vma + i,
|
section->vma + i,
|
||||||
&disasm_info);
|
&disasm_info,
|
||||||
|
false);
|
||||||
printf (":\n");
|
printf (":\n");
|
||||||
|
|
||||||
if (sym == NULL)
|
if (sym == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user