objdump --no-addresses
I find this useful when needing to compare compiler output, where the address of the instruction and the value of symbols results in unwanted differences. * objdump.c (no_addresses): New static var. (usage): Print help for --no-addresses. (long_options): Add --no-addresses entry. (objdump_print_addr_with_sym, objdump_print_addr): Omit symbol address. (disassemble_bytes): Don't print current line address, or reloc address. * doc/binutils.texi: Document objdump --no-addresses.
This commit is contained in:
parent
7ecb51549a
commit
b1bc1394df
3 changed files with 54 additions and 18 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2020-04-15 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* objdump.c (no_addresses): New static var.
|
||||||
|
(usage): Print help for --no-addresses.
|
||||||
|
(long_options): Add --no-addresses entry.
|
||||||
|
(objdump_print_addr_with_sym, objdump_print_addr): Omit symbol address.
|
||||||
|
(disassemble_bytes): Don't print current line address, or reloc
|
||||||
|
address.
|
||||||
|
* doc/binutils.texi: Document objdump --no-addresses.
|
||||||
|
|
||||||
2020-04-15 Alan Modra <amodra@gmail.com>
|
2020-04-15 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
PR 25822
|
PR 25822
|
||||||
|
|
|
@ -2161,6 +2161,7 @@ objdump [@option{-a}|@option{--archive-headers}]
|
||||||
[@option{-w}|@option{--wide}]
|
[@option{-w}|@option{--wide}]
|
||||||
[@option{--start-address=}@var{address}]
|
[@option{--start-address=}@var{address}]
|
||||||
[@option{--stop-address=}@var{address}]
|
[@option{--stop-address=}@var{address}]
|
||||||
|
[@option{--no-addresses}]
|
||||||
[@option{--prefix-addresses}]
|
[@option{--prefix-addresses}]
|
||||||
[@option{--[no-]show-raw-insn}]
|
[@option{--[no-]show-raw-insn}]
|
||||||
[@option{--adjust-vma=}@var{offset}]
|
[@option{--adjust-vma=}@var{offset}]
|
||||||
|
@ -2314,6 +2315,10 @@ Note if the @option{--dwarf=follow-links} option has also been enabled
|
||||||
then any symbol tables in linked debug info files will be read in and
|
then any symbol tables in linked debug info files will be read in and
|
||||||
used when disassembling.
|
used when disassembling.
|
||||||
|
|
||||||
|
@item --no-addresses
|
||||||
|
When disassembling, don't print addresses on each line or for symbols
|
||||||
|
and relocation offsets.
|
||||||
|
|
||||||
@item --prefix-addresses
|
@item --prefix-addresses
|
||||||
When disassembling, print the complete address on each line. This is
|
When disassembling, print the complete address on each line. This is
|
||||||
the older disassembly format.
|
the older disassembly format.
|
||||||
|
|
|
@ -93,6 +93,7 @@ static int dump_dynamic_reloc_info; /* -R */
|
||||||
static int dump_ar_hdrs; /* -a */
|
static int dump_ar_hdrs; /* -a */
|
||||||
static int dump_private_headers; /* -p */
|
static int dump_private_headers; /* -p */
|
||||||
static char *dump_private_options; /* -P */
|
static char *dump_private_options; /* -P */
|
||||||
|
static int no_addresses; /* --no-addresses */
|
||||||
static int prefix_addresses; /* --prefix-addresses */
|
static int prefix_addresses; /* --prefix-addresses */
|
||||||
static int with_line_numbers; /* -l */
|
static int with_line_numbers; /* -l */
|
||||||
static bfd_boolean with_source_code; /* -S */
|
static bfd_boolean with_source_code; /* -S */
|
||||||
|
@ -270,6 +271,7 @@ usage (FILE *stream, int status)
|
||||||
-z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\
|
-z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\
|
||||||
--start-address=ADDR Only process data whose address is >= ADDR\n\
|
--start-address=ADDR Only process data whose address is >= ADDR\n\
|
||||||
--stop-address=ADDR Only process data whose address is < ADDR\n\
|
--stop-address=ADDR Only process data whose address is < ADDR\n\
|
||||||
|
--no-addresses Do not print address alongside disassembly\n\
|
||||||
--prefix-addresses Print complete address alongside disassembly\n\
|
--prefix-addresses Print complete address alongside disassembly\n\
|
||||||
--[no-]show-raw-insn Display hex alongside symbolic disassembly\n\
|
--[no-]show-raw-insn Display hex alongside symbolic disassembly\n\
|
||||||
--insn-width=WIDTH Display WIDTH bytes on a single line for -d\n\
|
--insn-width=WIDTH Display WIDTH bytes on a single line for -d\n\
|
||||||
|
@ -358,6 +360,7 @@ static struct option long_options[]=
|
||||||
{"info", no_argument, NULL, 'i'},
|
{"info", no_argument, NULL, 'i'},
|
||||||
{"line-numbers", no_argument, NULL, 'l'},
|
{"line-numbers", no_argument, NULL, 'l'},
|
||||||
{"no-show-raw-insn", no_argument, &show_raw_insn, -1},
|
{"no-show-raw-insn", no_argument, &show_raw_insn, -1},
|
||||||
|
{"no-addresses", no_argument, &no_addresses, 1},
|
||||||
{"prefix-addresses", no_argument, &prefix_addresses, 1},
|
{"prefix-addresses", no_argument, &prefix_addresses, 1},
|
||||||
{"recurse-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
|
{"recurse-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
|
||||||
{"recursion-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
|
{"recursion-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
|
||||||
|
@ -1303,13 +1306,17 @@ objdump_print_addr_with_sym (bfd *abfd, asection *sec, asymbol *sym,
|
||||||
bfd_vma vma, struct disassemble_info *inf,
|
bfd_vma vma, struct disassemble_info *inf,
|
||||||
bfd_boolean skip_zeroes)
|
bfd_boolean skip_zeroes)
|
||||||
{
|
{
|
||||||
objdump_print_value (vma, inf, skip_zeroes);
|
if (!no_addresses)
|
||||||
|
{
|
||||||
|
objdump_print_value (vma, inf, skip_zeroes);
|
||||||
|
(*inf->fprintf_func) (inf->stream, " ");
|
||||||
|
}
|
||||||
|
|
||||||
if (sym == NULL)
|
if (sym == NULL)
|
||||||
{
|
{
|
||||||
bfd_vma secaddr;
|
bfd_vma secaddr;
|
||||||
|
|
||||||
(*inf->fprintf_func) (inf->stream, " <%s",
|
(*inf->fprintf_func) (inf->stream, "<%s",
|
||||||
sanitize_string (bfd_section_name (sec)));
|
sanitize_string (bfd_section_name (sec)));
|
||||||
secaddr = bfd_section_vma (sec);
|
secaddr = bfd_section_vma (sec);
|
||||||
if (vma < secaddr)
|
if (vma < secaddr)
|
||||||
|
@ -1326,7 +1333,7 @@ objdump_print_addr_with_sym (bfd *abfd, asection *sec, asymbol *sym,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*inf->fprintf_func) (inf->stream, " <");
|
(*inf->fprintf_func) (inf->stream, "<");
|
||||||
|
|
||||||
objdump_print_symname (abfd, inf, sym);
|
objdump_print_symname (abfd, inf, sym);
|
||||||
|
|
||||||
|
@ -1376,8 +1383,11 @@ objdump_print_addr (bfd_vma vma,
|
||||||
|
|
||||||
if (sorted_symcount < 1)
|
if (sorted_symcount < 1)
|
||||||
{
|
{
|
||||||
(*inf->fprintf_func) (inf->stream, "0x");
|
if (!no_addresses)
|
||||||
objdump_print_value (vma, inf, skip_zeroes);
|
{
|
||||||
|
(*inf->fprintf_func) (inf->stream, "0x");
|
||||||
|
objdump_print_value (vma, inf, skip_zeroes);
|
||||||
|
}
|
||||||
|
|
||||||
if (display_file_offsets)
|
if (display_file_offsets)
|
||||||
inf->fprintf_func (inf->stream, _(" (File Offset: 0x%lx)"),
|
inf->fprintf_func (inf->stream, _(" (File Offset: 0x%lx)"),
|
||||||
|
@ -2573,7 +2583,7 @@ disassemble_bytes (struct disassemble_info * inf,
|
||||||
zeroes in chunks of 4, ensuring that there is always a leading
|
zeroes in chunks of 4, ensuring that there is always a leading
|
||||||
zero remaining. */
|
zero remaining. */
|
||||||
skip_addr_chars = 0;
|
skip_addr_chars = 0;
|
||||||
if (! prefix_addresses)
|
if (!no_addresses && !prefix_addresses)
|
||||||
{
|
{
|
||||||
char buf[30];
|
char buf[30];
|
||||||
|
|
||||||
|
@ -2669,7 +2679,9 @@ disassemble_bytes (struct disassemble_info * inf,
|
||||||
if (with_line_numbers || with_source_code)
|
if (with_line_numbers || with_source_code)
|
||||||
show_line (aux->abfd, section, addr_offset);
|
show_line (aux->abfd, section, addr_offset);
|
||||||
|
|
||||||
if (! prefix_addresses)
|
if (no_addresses)
|
||||||
|
printf ("\t");
|
||||||
|
else if (!prefix_addresses)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
|
@ -2875,12 +2887,17 @@ disassemble_bytes (struct disassemble_info * inf,
|
||||||
putchar ('\n');
|
putchar ('\n');
|
||||||
j = addr_offset * opb + pb;
|
j = addr_offset * opb + pb;
|
||||||
|
|
||||||
bfd_sprintf_vma (aux->abfd, buf, section->vma + j / opb);
|
if (no_addresses)
|
||||||
for (s = buf + skip_addr_chars; *s == '0'; s++)
|
printf ("\t");
|
||||||
*s = ' ';
|
else
|
||||||
if (*s == '\0')
|
{
|
||||||
*--s = '0';
|
bfd_sprintf_vma (aux->abfd, buf, section->vma + j / opb);
|
||||||
printf ("%s:\t", buf + skip_addr_chars);
|
for (s = buf + skip_addr_chars; *s == '0'; s++)
|
||||||
|
*s = ' ';
|
||||||
|
if (*s == '\0')
|
||||||
|
*--s = '0';
|
||||||
|
printf ("%s:\t", buf + skip_addr_chars);
|
||||||
|
}
|
||||||
|
|
||||||
print_jump_visualisation (section->vma + j / opb,
|
print_jump_visualisation (section->vma + j / opb,
|
||||||
max_level, line_buffer,
|
max_level, line_buffer,
|
||||||
|
@ -2932,15 +2949,19 @@ disassemble_bytes (struct disassemble_info * inf,
|
||||||
else
|
else
|
||||||
printf ("\t\t\t");
|
printf ("\t\t\t");
|
||||||
|
|
||||||
objdump_print_value (section->vma - rel_offset + q->address,
|
if (!no_addresses)
|
||||||
inf, TRUE);
|
{
|
||||||
|
objdump_print_value (section->vma - rel_offset + q->address,
|
||||||
|
inf, TRUE);
|
||||||
|
printf (": ");
|
||||||
|
}
|
||||||
|
|
||||||
if (q->howto == NULL)
|
if (q->howto == NULL)
|
||||||
printf (": *unknown*\t");
|
printf ("*unknown*\t");
|
||||||
else if (q->howto->name)
|
else if (q->howto->name)
|
||||||
printf (": %s\t", q->howto->name);
|
printf ("%s\t", q->howto->name);
|
||||||
else
|
else
|
||||||
printf (": %d\t", q->howto->type);
|
printf ("%d\t", q->howto->type);
|
||||||
|
|
||||||
if (q->sym_ptr_ptr == NULL || *q->sym_ptr_ptr == NULL)
|
if (q->sym_ptr_ptr == NULL || *q->sym_ptr_ptr == NULL)
|
||||||
printf ("*unknown*");
|
printf ("*unknown*");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue