+ l = linenumber - SHOW_PRECEDING_CONTEXT_LINES;
+ if (l >= linenumber)
+ l = 1;
+ if (p->last_line >= l && p->last_line <= linenumber)
+ l = p->last_line + 1;
+ }
+ dump_lines (p, l, linenumber);
+ p->last_line = linenumber;
+ p->first = 0;
+ }
+ }
+
+ if (functionname != NULL
+ && (prev_functionname == NULL
+ || strcmp (functionname, prev_functionname) != 0))
+ {
+ if (prev_functionname != NULL)
+ free (prev_functionname);
+ prev_functionname = (char *) xmalloc (strlen (functionname) + 1);
+ strcpy (prev_functionname, functionname);
+ }
+
+ if (linenumber > 0 && linenumber != prev_line)
+ prev_line = linenumber;
+
+ if (discriminator != prev_discriminator)
+ prev_discriminator = discriminator;
+}
+
+/* Pseudo FILE object for strings. */
+typedef struct
+{
+ char *buffer;
+ size_t pos;
+ size_t alloc;
+} SFILE;
+
+/* sprintf to a "stream". */
+
+static int ATTRIBUTE_PRINTF_2
+objdump_sprintf (SFILE *f, const char *format, ...)
+{
+ size_t n;
+ va_list args;
+
+ while (1)
+ {
+ size_t space = f->alloc - f->pos;
+
+ va_start (args, format);
+ n = vsnprintf (f->buffer + f->pos, space, format, args);
+ va_end (args);
+
+ if (space > n)
+ break;
+
+ f->alloc = (f->alloc + n) * 2;
+ f->buffer = (char *) xrealloc (f->buffer, f->alloc);
+ }
+ f->pos += n;
+
+ return n;
+}
+
+/* The number of zeroes we want to see before we start skipping them.
+ The number is arbitrarily chosen. */
+
+#define DEFAULT_SKIP_ZEROES 8
+
+/* The number of zeroes to skip at the end of a section. If the
+ number of zeroes at the end is between SKIP_ZEROES_AT_END and
+ SKIP_ZEROES, they will be disassembled. If there are fewer than
+ SKIP_ZEROES_AT_END, they will be skipped. This is a heuristic
+ attempt to avoid disassembling zeroes inserted by section
+ alignment. */
+
+#define DEFAULT_SKIP_ZEROES_AT_END 3
+
+/* Disassemble some data in memory between given values. */
+
+static void
+disassemble_bytes (struct disassemble_info * inf,
+ disassembler_ftype disassemble_fn,
+ bfd_boolean insns,
+ bfd_byte * data,
+ bfd_vma start_offset,
+ bfd_vma stop_offset,
+ bfd_vma rel_offset,
+ arelent *** relppp,
+ arelent ** relppend)
+{
+ struct objdump_disasm_info *aux;
+ asection *section;
+ int octets_per_line;
+ 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;
+ SFILE sfile;
+
+ aux = (struct objdump_disasm_info *) inf->application_data;
+ section = aux->sec;
+
+ sfile.alloc = 120;
+ sfile.buffer = (char *) xmalloc (sfile.alloc);
+ sfile.pos = 0;
+
+ if (insn_width)
+ octets_per_line = insn_width;
+ else if (insns)
+ octets_per_line = 4;
+ else
+ octets_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];
+
+ bfd_sprintf_vma (aux->abfd, buf, section->vma + section->size / opb);
+
+ while (buf[skip_addr_chars] == '0')
+ ++skip_addr_chars;
+
+ /* Don't discard zeros on overflow. */
+ if (buf[skip_addr_chars] == '\0' && section->vma != 0)
+ skip_addr_chars = 0;
+
+ if (skip_addr_chars != 0)
+ skip_addr_chars = (skip_addr_chars - 1) & -4;
+ }
+
+ inf->insn_info_valid = 0;
+
+ addr_offset = start_offset;
+ while (addr_offset < stop_offset)
+ {
+ bfd_vma z;
+ bfd_boolean need_nl = FALSE;
+ int previous_octets;
+
+ /* Remember the length of the previous instruction. */
+ previous_octets = octets;
+ octets = 0;
+
+ /* Make sure we don't use relocs from previous instructions. */
+ aux->reloc = NULL;
+
+ /* 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
+ && (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)))
+ {
+ /* 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 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,
+ (unsigned long) (section->filepos
+ + (addr_offset + (octets / opb))));
+ else
+ printf ("\t...\n");
+ }
+ else
+ {
+ char buf[50];
+ int bpc = 0;
+ int pb = 0;
+
+ if (with_line_numbers || with_source_code)
+ show_line (aux->abfd, section, addr_offset);
+
+ if (! prefix_addresses)
+ {
+ char *s;
+
+ bfd_sprintf_vma (aux->abfd, buf, section->vma + addr_offset);
+ for (s = buf + skip_addr_chars; *s == '0'; s++)
+ *s = ' ';
+ if (*s == '\0')
+ *--s = '0';
+ printf ("%s:\t", buf + skip_addr_chars);
+ }
+ else
+ {
+ aux->require_sec = TRUE;
+ objdump_print_address (section->vma + addr_offset, inf);
+ aux->require_sec = FALSE;
+ putchar (' ');
+ }
+
+ if (insns)
+ {
+ sfile.pos = 0;
+ inf->fprintf_func = (fprintf_ftype) objdump_sprintf;
+ inf->stream = &sfile;
+ inf->bytes_per_line = 0;
+ inf->bytes_per_chunk = 0;
+ inf->flags = disassemble_all ? DISASSEMBLE_DATA : 0;
+ if (machine)
+ inf->flags |= USER_SPECIFIED_MACHINE_TYPE;
+
+ if (inf->disassembler_needs_relocs
+ && (bfd_get_file_flags (aux->abfd) & EXEC_P) == 0
+ && (bfd_get_file_flags (aux->abfd) & DYNAMIC) == 0
+ && *relppp < relppend)