gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / binutils / objdump.c
index 81c0b4f3d065fe939a7aee8a66235bc30341c466..99e6df6eb17fbc7b07f439e8455fa534dd4dea98 100644 (file)
@@ -93,6 +93,7 @@ static int dump_dynamic_reloc_info;   /* -R */
 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 */
@@ -270,6 +271,7 @@ usage (FILE *stream, int status)
   -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\
@@ -358,6 +360,7 @@ static struct option long_options[]=
   {"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},
@@ -1303,13 +1306,17 @@ objdump_print_addr_with_sym (bfd *abfd, asection *sec, asymbol *sym,
                             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)
@@ -1326,7 +1333,7 @@ objdump_print_addr_with_sym (bfd *abfd, asection *sec, asymbol *sym,
     }
   else
     {
-      (*inf->fprintf_func) (inf->stream, " <");
+      (*inf->fprintf_func) (inf->stream, "<");
 
       objdump_print_symname (abfd, inf, sym);
 
@@ -1376,8 +1383,11 @@ objdump_print_addr (bfd_vma vma,
 
   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)"),
@@ -2545,13 +2555,13 @@ disassemble_bytes (struct disassemble_info * inf,
 {
   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;
@@ -2573,7 +2583,7 @@ disassemble_bytes (struct disassemble_info * inf,
      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];
 
@@ -2620,7 +2630,6 @@ disassemble_bytes (struct disassemble_info * inf,
   addr_offset = start_offset;
   while (addr_offset < stop_offset)
     {
-      bfd_vma z;
       bfd_boolean need_nl = FALSE;
 
       octets = 0;
@@ -2630,46 +2639,49 @@ disassemble_bytes (struct disassemble_info * inf,
 
       /* 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;
 
@@ -2694,6 +2706,8 @@ disassemble_bytes (struct disassemble_info * inf,
 
          if (insns)
            {
+             int insn_size;
+
              sfile.pos = 0;
              inf->fprintf_func = (fprintf_ftype) objdump_sprintf;
              inf->stream = &sfile;
@@ -2710,13 +2724,13 @@ disassemble_bytes (struct disassemble_info * inf,
                  && *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))
@@ -2757,8 +2771,8 @@ disassemble_bytes (struct disassemble_info * inf,
                }
 
              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
@@ -2766,21 +2780,22 @@ disassemble_bytes (struct disassemble_info * inf,
                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;
@@ -2826,11 +2841,11 @@ disassemble_bytes (struct disassemble_info * inf,
                  /* 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
@@ -2844,7 +2859,7 @@ disassemble_bytes (struct disassemble_info * inf,
 
              for (; pb < octets_per_line; pb += bpc)
                {
-                 int k;
+                 unsigned int k;
 
                  for (k = 0; k < bpc; k++)
                    printf ("  ");
@@ -2875,12 +2890,17 @@ disassemble_bytes (struct disassemble_info * inf,
                  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,
@@ -2894,11 +2914,11 @@ disassemble_bytes (struct disassemble_info * inf,
                      /* 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
@@ -2932,15 +2952,19 @@ disassemble_bytes (struct disassemble_info * inf,
              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*");
This page took 0.028964 seconds and 4 git commands to generate.