static int dump_ar_hdrs; /* -a */
static int dump_private_headers; /* -p */
static char *dump_private_options; /* -P */
+static int no_addresses; /* --no-addresses */
static int prefix_addresses; /* --prefix-addresses */
static int with_line_numbers; /* -l */
static bfd_boolean with_source_code; /* -S */
-z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\
--start-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\
--[no-]show-raw-insn Display hex alongside symbolic disassembly\n\
--insn-width=WIDTH Display WIDTH bytes on a single line for -d\n\
{"info", no_argument, NULL, 'i'},
{"line-numbers", no_argument, NULL, 'l'},
{"no-show-raw-insn", no_argument, &show_raw_insn, -1},
+ {"no-addresses", no_argument, &no_addresses, 1},
{"prefix-addresses", no_argument, &prefix_addresses, 1},
{"recurse-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
{"recursion-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
}
if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0)
- version_string = bfd_get_symbol_version_string (abfd, sym, &hidden);
+ version_string = bfd_get_symbol_version_string (abfd, sym, TRUE,
+ &hidden);
if (bfd_is_und_section (bfd_asymbol_section (sym)))
hidden = TRUE;
{
if (want_section)
{
+ /* NB: An object file can have different sections with the same
+ section name. Compare compare section pointers if they have
+ the same owner. */
+ if (sorted_syms[place]->section->owner == sec->owner
+ && sorted_syms[place]->section != sec)
+ return FALSE;
+
/* Note - we cannot just compare section pointers because they could
be different, but the same... Ie the symbol that we are trying to
find could have come from a separate debug info file. Under such
bfd_vma vma, struct disassemble_info *inf,
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)
{
bfd_vma secaddr;
- (*inf->fprintf_func) (inf->stream, " <%s",
+ (*inf->fprintf_func) (inf->stream, "<%s",
sanitize_string (bfd_section_name (sec)));
secaddr = bfd_section_vma (sec);
if (vma < secaddr)
}
else
{
- (*inf->fprintf_func) (inf->stream, " <");
+ (*inf->fprintf_func) (inf->stream, "<");
objdump_print_symname (abfd, inf, sym);
if (sorted_symcount < 1)
{
- (*inf->fprintf_func) (inf->stream, "0x");
- objdump_print_value (vma, inf, skip_zeroes);
+ if (!no_addresses)
+ {
+ (*inf->fprintf_func) (inf->stream, "0x");
+ objdump_print_value (vma, inf, skip_zeroes);
+ }
if (display_file_offsets)
inf->fprintf_func (inf->stream, _(" (File Offset: 0x%lx)"),
/* Skip selected directory levels. */
for (s = fname + 1; *s != '\0' && level < prefix_strip; s++)
- if (IS_DIR_SEPARATOR(*s))
+ if (IS_DIR_SEPARATOR (*s))
{
fname = s;
level++;
&& (prev_functionname == NULL
|| strcmp (functionname, prev_functionname) != 0))
{
- printf ("%s():\n", sanitize_string (functionname));
+ char *demangle_alloc = NULL;
+ if (do_demangle && functionname[0] != '\0')
+ {
+ /* Demangle the name. */
+ demangle_alloc = bfd_demangle (abfd, functionname,
+ demangle_flags);
+ }
+
+ /* Demangling adds trailing parens, so don't print those. */
+ if (demangle_alloc != NULL)
+ printf ("%s:\n", sanitize_string (demangle_alloc));
+ else
+ printf ("%s():\n", sanitize_string (functionname));
+
prev_line = -1;
+ free (demangle_alloc);
}
if (linenumber > 0
&& (linenumber != prev_line
a->start.max_count += b->start.max_count;
a->start.addresses =
xrealloc (a->start.addresses,
- a->start.max_count * sizeof(bfd_vma *));
+ a->start.max_count * sizeof (bfd_vma *));
}
/* Append start addresses. */
/* Visualize all jumps at a given address. */
static void
-jump_info_visualize_address (const struct jump_info *jumps,
- bfd_vma address,
+jump_info_visualize_address (bfd_vma address,
int max_level,
char *line_buffer,
uint8_t *color_buffer)
{
+ struct jump_info *ji = detected_jumps;
size_t len = (max_level + 1) * 3;
- const struct jump_info *ji;
/* Clear line buffer. */
- memset(line_buffer, ' ', len);
- memset(color_buffer, 0, len);
+ memset (line_buffer, ' ', len);
+ memset (color_buffer, 0, len);
/* Iterate over jumps and add their ASCII art. */
- for (ji = jumps; ji; ji = ji->next)
+ while (ji)
{
- if ((jump_info_min_address (ji) <= address)
- && (jump_info_max_address (ji) >= address))
+ /* Discard jumps that are never needed again. */
+ if (jump_info_max_address (ji) < address)
+ {
+ struct jump_info *tmp = ji;
+
+ ji = ji->next;
+ jump_info_unlink (tmp, &detected_jumps);
+ jump_info_free (tmp);
+ continue;
+ }
+
+ /* This jump intersects with the current address. */
+ if (jump_info_min_address (ji) <= address)
{
/* Hash target address to get an even
distribution between all values. */
color_buffer[offset] = color;
}
}
+
+ ji = ji->next;
}
}
return 1;
}
+/* Print out jump visualization. */
+
+static void
+print_jump_visualisation (bfd_vma addr, int max_level, char *line_buffer,
+ uint8_t *color_buffer)
+{
+ if (!line_buffer)
+ return;
+
+ jump_info_visualize_address (addr, max_level, line_buffer, color_buffer);
+
+ size_t line_buffer_size = strlen (line_buffer);
+ char last_color = 0;
+ size_t i;
+
+ for (i = 0; i <= line_buffer_size; ++i)
+ {
+ if (color_output)
+ {
+ uint8_t color = (i < line_buffer_size) ? color_buffer[i]: 0;
+
+ if (color != last_color)
+ {
+ if (color)
+ if (extended_color_output)
+ /* Use extended 8bit color, but
+ do not choose dark colors. */
+ printf ("\033[38;5;%dm", 124 + (color % 108));
+ else
+ /* Use simple terminal colors. */
+ printf ("\033[%dm", 31 + (color % 7));
+ else
+ /* Clear color. */
+ printf ("\033[0m");
+ last_color = color;
+ }
+ }
+ putchar ((i < line_buffer_size) ? line_buffer[i]: ' ');
+ }
+}
+
/* Disassemble some data in memory between given values. */
static void
{
struct objdump_disasm_info *aux;
asection *section;
- int octets_per_line;
- int skip_addr_chars;
+ unsigned int octets_per_line;
+ unsigned int skip_addr_chars;
bfd_vma addr_offset;
unsigned int opb = inf->octets_per_byte;
unsigned int skip_zeroes = inf->skip_zeroes;
unsigned int skip_zeroes_at_end = inf->skip_zeroes_at_end;
- int octets = opb;
+ size_t octets;
SFILE sfile;
aux = (struct objdump_disasm_info *) inf->application_data;
zeroes in chunks of 4, ensuring that there is always a leading
zero remaining. */
skip_addr_chars = 0;
- if (! prefix_addresses)
+ if (!no_addresses && !prefix_addresses)
{
char buf[30];
inf->insn_info_valid = 0;
/* Determine maximum level. */
+ uint8_t *color_buffer = NULL;
+ char *line_buffer = NULL;
int max_level = -1;
- struct jump_info *base = detected_jumps ? detected_jumps : NULL;
- struct jump_info *ji;
- for (ji = base; ji; ji = ji->next)
+ /* Some jumps were detected. */
+ if (detected_jumps)
{
- if (ji->level > max_level)
+ struct jump_info *ji;
+
+ /* Find maximum jump level. */
+ for (ji = detected_jumps; ji; ji = ji->next)
{
- max_level = ji->level;
+ if (ji->level > max_level)
+ max_level = ji->level;
}
- }
- /* Allocate line buffer if there are any jumps. */
- size_t len = (max_level + 1) * 3 + 1;
- char *line_buffer = (max_level >= 0) ? xmalloc(len): NULL;
- uint8_t *color_buffer = (max_level >= 0) ? xmalloc(len): NULL;
-
- if (line_buffer)
- {
+ /* Allocate buffers. */
+ size_t len = (max_level + 1) * 3 + 1;
+ line_buffer = xmalloc (len);
line_buffer[len - 1] = 0;
+ color_buffer = xmalloc (len);
color_buffer[len - 1] = 0;
}
addr_offset = start_offset;
while (addr_offset < stop_offset)
{
- bfd_vma z;
bfd_boolean need_nl = FALSE;
octets = 0;
/* If we see more than SKIP_ZEROES octets of zeroes, we just
print `...'. */
- for (z = addr_offset * opb; z < stop_offset * opb; z++)
- if (data[z] != 0)
- break;
+ if (! disassemble_zeroes)
+ for (; addr_offset * opb + octets < stop_offset * opb; octets++)
+ if (data[addr_offset * opb + octets] != 0)
+ break;
if (! disassemble_zeroes
&& (inf->insn_info_valid == 0
|| inf->branch_delay_insns == 0)
- && (z - addr_offset * opb >= skip_zeroes
- || (z == stop_offset * opb &&
- z - addr_offset * opb < skip_zeroes_at_end)))
+ && (octets >= skip_zeroes
+ || (addr_offset * opb + octets == stop_offset * opb
+ && octets < skip_zeroes_at_end)))
{
/* If there are more nonzero octets to follow, we only skip
zeroes in multiples of 4, to try to avoid running over
the start of an instruction which happens to start with
zero. */
- if (z != stop_offset * opb)
- z = addr_offset * opb + ((z - addr_offset * opb) &~ 3);
-
- octets = z - addr_offset * opb;
+ if (addr_offset * opb + octets != stop_offset * opb)
+ octets &= ~3;
/* If we are going to display more data, and we are displaying
file offsets, then tell the user how many zeroes we skip
and the file offset from where we resume dumping. */
- if (display_file_offsets && ((addr_offset + (octets / opb)) < stop_offset))
- printf ("\t... (skipping %d zeroes, resuming at file offset: 0x%lx)\n",
- octets / opb,
+ if (display_file_offsets
+ && addr_offset + octets / opb < stop_offset)
+ printf (_("\t... (skipping %lu zeroes, "
+ "resuming at file offset: 0x%lx)\n"),
+ (unsigned long) (octets / opb),
(unsigned long) (section->filepos
- + (addr_offset + (octets / opb))));
+ + addr_offset + octets / opb));
else
printf ("\t...\n");
}
else
{
char buf[50];
- int bpc = 0;
- int pb = 0;
+ unsigned int bpc = 0;
+ unsigned int pb = 0;
if (with_line_numbers || with_source_code)
show_line (aux->abfd, section, addr_offset);
- if (! prefix_addresses)
+ if (no_addresses)
+ printf ("\t");
+ else if (!prefix_addresses)
{
char *s;
putchar (' ');
}
- /* Visualize jumps. */
- if (line_buffer)
- {
- jump_info_visualize_address (base,
- section->vma + addr_offset,
- max_level,
- line_buffer,
- color_buffer);
-
- size_t line_buffer_size = strlen (line_buffer);
- char last_color = 0;
- size_t i;
-
- for (i = 0; i <= line_buffer_size; ++i)
- {
- if (color_output)
- {
- uint8_t color = (i < line_buffer_size) ? color_buffer[i]: 0;
-
- if (color != last_color)
- {
- if (color)
- if (extended_color_output)
- /* Use extended 8bit color, but
- do not choose dark colors. */
- printf ("\033[38;5;%dm", 124 + (color % 108));
- else
- /* Use simple terminal colors. */
- printf ("\033[%dm", 31 + (color % 7));
- else
- /* Clear color. */
- printf ("\033[0m");
- last_color = color;
- }
- }
- putchar ((i < line_buffer_size) ? line_buffer[i]: ' ');
- }
- }
+ print_jump_visualisation (section->vma + addr_offset,
+ max_level, line_buffer,
+ color_buffer);
if (insns)
{
+ int insn_size;
+
sfile.pos = 0;
inf->fprintf_func = (fprintf_ftype) objdump_sprintf;
inf->stream = &sfile;
&& *relppp < relppend)
{
bfd_signed_vma distance_to_rel;
- int insn_size = 0;
int max_reloc_offset
= aux->abfd->arch_info->max_reloc_offset_into_insn;
distance_to_rel = ((**relppp)->address - rel_offset
- addr_offset);
+ insn_size = 0;
if (distance_to_rel > 0
&& (max_reloc_offset < 0
|| distance_to_rel <= max_reloc_offset))
}
if (! disassemble_all
- && (section->flags & (SEC_CODE | SEC_HAS_CONTENTS))
- == (SEC_CODE | SEC_HAS_CONTENTS))
+ && ((section->flags & (SEC_CODE | SEC_HAS_CONTENTS))
+ == (SEC_CODE | SEC_HAS_CONTENTS)))
/* Set a stop_vma so that the disassembler will not read
beyond the next symbol. We assume that symbols appear on
the boundaries between instructions. We only do this when
inf->stop_vma = section->vma + stop_offset;
inf->stop_offset = stop_offset;
- octets = (*disassemble_fn) (section->vma + addr_offset, inf);
+ insn_size = (*disassemble_fn) (section->vma + addr_offset, inf);
+ octets = insn_size;
inf->stop_vma = 0;
inf->fprintf_func = (fprintf_ftype) fprintf;
inf->stream = stdout;
if (insn_width == 0 && inf->bytes_per_line != 0)
octets_per_line = inf->bytes_per_line;
- if (octets < (int) opb)
+ if (insn_size < (int) opb)
{
if (sfile.pos)
printf ("%s\n", sfile.buffer);
- if (octets >= 0)
+ if (insn_size >= 0)
{
non_fatal (_("disassemble_fn returned length %d"),
- octets);
+ insn_size);
exit_status = 1;
}
break;
/* PR 21580: Check for a buffer ending early. */
if (j + bpc <= stop_offset * opb)
{
- int k;
+ unsigned int k;
if (inf->display_endian == BFD_ENDIAN_LITTLE)
{
- for (k = bpc - 1; k >= 0; k--)
+ for (k = bpc; k-- != 0; )
printf ("%02x", (unsigned) data[j + k]);
}
else
for (; pb < octets_per_line; pb += bpc)
{
- int k;
+ unsigned int k;
for (k = 0; k < bpc; k++)
printf (" ");
putchar ('\n');
j = addr_offset * opb + pb;
- bfd_sprintf_vma (aux->abfd, buf, section->vma + j / opb);
- for (s = buf + skip_addr_chars; *s == '0'; s++)
- *s = ' ';
- if (*s == '\0')
- *--s = '0';
- printf ("%s:\t", buf + skip_addr_chars);
+ if (no_addresses)
+ printf ("\t");
+ else
+ {
+ bfd_sprintf_vma (aux->abfd, buf, section->vma + j / opb);
+ 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,
+ max_level, line_buffer,
+ color_buffer);
pb += octets_per_line;
if (pb > octets)
/* PR 21619: Check for a buffer ending early. */
if (j + bpc <= stop_offset * opb)
{
- int k;
+ unsigned int k;
if (inf->display_endian == BFD_ENDIAN_LITTLE)
{
- for (k = bpc - 1; k >= 0; k--)
+ for (k = bpc; k-- != 0; )
printf ("%02x", (unsigned) data[j + k]);
}
else
else
printf ("\t\t\t");
- objdump_print_value (section->vma - rel_offset + q->address,
- inf, TRUE);
+ if (!no_addresses)
+ {
+ objdump_print_value (section->vma - rel_offset + q->address,
+ inf, TRUE);
+ printf (": ");
+ }
if (q->howto == NULL)
- printf (": *unknown*\t");
+ printf ("*unknown*\t");
else if (q->howto->name)
- printf (": %s\t", q->howto->name);
+ printf ("%s\t", q->howto->name);
else
- printf (": %d\t", q->howto->type);
+ printf ("%d\t", q->howto->type);
if (q->sym_ptr_ptr == NULL || *q->sym_ptr_ptr == NULL)
printf ("*unknown*");
/* Sort the symbols into value and section order. */
compare_section = section;
- qsort (sorted_syms, sorted_symcount, sizeof (asymbol *), compare_symbols);
+ if (sorted_symcount > 1)
+ qsort (sorted_syms, sorted_symcount, sizeof (asymbol *), compare_symbols);
/* Skip over the relocs belonging to addresses below the
start address. */
sorted_symcount = symcount ? symcount : dynsymcount;
sorted_syms = (asymbol **) xmalloc ((sorted_symcount + synthcount)
* sizeof (asymbol *));
- memcpy (sorted_syms, symcount ? syms : dynsyms,
- sorted_symcount * sizeof (asymbol *));
+ if (sorted_symcount != 0)
+ {
+ memcpy (sorted_syms, symcount ? syms : dynsyms,
+ sorted_symcount * sizeof (asymbol *));
- sorted_symcount = remove_useless_symbols (sorted_syms, sorted_symcount);
+ sorted_symcount = remove_useless_symbols (sorted_syms, sorted_symcount);
+ }
for (i = 0; i < synthcount; ++i)
{
bfd_get_mach (abfd)));
printf (_("flags 0x%08x:\n"), abfd->flags & ~BFD_FLAGS_FOR_BFD_USE_MASK);
-#define PF(x, y) if (abfd->flags & x) {printf("%s%s", comma, y); comma=", ";}
+#define PF(x, y) if (abfd->flags & x) {printf ("%s%s", comma, y); comma=", ";}
PF (HAS_RELOC, "HAS_RELOC");
PF (EXEC_P, "EXEC_P");
PF (HAS_LINENO, "HAS_LINENO");
Undo this transformation, otherwise the output
will be confusing. */
if (abfd->xvec->flavour == bfd_target_elf_flavour
- && elf_tdata(abfd)->elf_header->e_machine == EM_SPARCV9
+ && elf_tdata (abfd)->elf_header->e_machine == EM_SPARCV9
&& relcount > 1
&& !strcmp (q->howto->name, "R_SPARC_LO10"))
{