{
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
/* 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
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;
}
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;
-
- for (size_t 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)
{
*--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)
pb = octets;
/* 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"))
{