Fix up changelog entry of previous delta
[binutils-gdb.git] / binutils / objdump.c
index 99e6df6eb17fbc7b07f439e8455fa534dd4dea98..91da48095f37b116ec589223ff36e9789c6ab03b 100644 (file)
@@ -229,13 +229,19 @@ usage (FILE *stream, int status)
   -g, --debugging          Display debug information in object file\n\
   -e, --debugging-tags     Display debug information using ctags style\n\
   -G, --stabs              Display (in raw form) any STABS info in the file\n\
-  -W[lLiaprmfFsoRtUuTgAckK] or\n\
+  -W[lLiaprmfFsoORtUuTgAckK] or\n\
   --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,\n\
-          =frames-interp,=str,=loc,=Ranges,=pubtypes,\n\
+          =frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,\n\
           =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,\n\
           =addr,=cu_index,=links,=follow-links]\n\
                            Display DWARF info in the file\n\
+"));
+#ifdef ENABLE_LIBCTF
+  fprintf (stream, _("\
   --ctf=SECTION            Display CTF info from SECTION\n\
+"));
+#endif
+  fprintf (stream, _("\
   -t, --syms               Display the contents of the symbol table(s)\n\
   -T, --dynamic-syms       Display the contents of the dynamic symbol table\n\
   -r, --reloc              Display the relocation entries in the file\n\
@@ -284,9 +290,12 @@ usage (FILE *stream, int status)
       --dwarf-depth=N        Do not display DIEs at depth N or greater\n\
       --dwarf-start=N        Display DIEs starting with N, at the same depth\n\
                              or deeper\n\
-      --dwarf-check          Make additional dwarf internal consistency checks.\
-      \n\
-      --ctf-parent=SECTION       Use SECTION as the CTF parent\n\
+      --dwarf-check          Make additional dwarf internal consistency checks.\n"));
+#ifdef ENABLE_LIBCTF
+      fprintf (stream, _("\
+      --ctf-parent=SECTION     Use SECTION as the CTF parent\n"));
+#endif
+      fprintf (stream, _("\
       --visualize-jumps          Visualize jumps by drawing ASCII art lines\n\
       --visualize-jumps=color    Use colors in the ASCII art\n\
       --visualize-jumps=extended-color   Use extended 8-bit color codes\n\
@@ -328,8 +337,10 @@ enum option_values
     OPTION_NO_RECURSE_LIMIT,
     OPTION_INLINES,
     OPTION_SOURCE_COMMENT,
+#ifdef ENABLE_LIBCTF
     OPTION_CTF,
     OPTION_CTF_PARENT,
+#endif
     OPTION_VISUALIZE_JUMPS
   };
 
@@ -375,8 +386,10 @@ static struct option long_options[]=
   {"special-syms", no_argument, &dump_special_syms, 1},
   {"include", required_argument, NULL, 'I'},
   {"dwarf", optional_argument, NULL, OPTION_DWARF},
+#ifdef ENABLE_LIBCTF
   {"ctf", required_argument, NULL, OPTION_CTF},
   {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT},
+#endif
   {"stabs", no_argument, NULL, 'G'},
   {"start-address", required_argument, NULL, OPTION_START_ADDRESS},
   {"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS},
@@ -2989,8 +3002,8 @@ disassemble_bytes (struct disassemble_info * inf,
 
              if (q->addend)
                {
-                 bfd_signed_vma addend = q->addend;
-                 if (addend < 0)
+                 bfd_vma addend = q->addend;
+                 if ((bfd_signed_vma) addend < 0)
                    {
                      printf ("-0x");
                      addend = -addend;
@@ -3479,6 +3492,8 @@ disassemble_data (bfd *abfd)
        instead.  */
     disasm_info.endian = BFD_ENDIAN_UNKNOWN;
 
+  disasm_info.endian_code = disasm_info.endian;
+
   /* Allow the target to customize the info structure.  */
   disassemble_init_for_target (& disasm_info);
 
@@ -4024,6 +4039,7 @@ dump_bfd_header (bfd *abfd)
 }
 \f
 
+#ifdef ENABLE_LIBCTF
 /* Formatting callback function passed to ctf_dump.  Returns either the pointer
    it is passed, or a pointer to newly-allocated storage, in which case
    dump_ctf() will free it when it no longer needs it.  */
@@ -4055,6 +4071,29 @@ make_ctfsect (const char *name, bfd_byte *data,
   return ctfsect;
 }
 
+/* Dump CTF errors/warnings.  */
+static void
+dump_ctf_errs (ctf_file_t *fp)
+{
+  ctf_next_t *it = NULL;
+  char *errtext;
+  int is_warning;
+  int err;
+
+  /* Dump accumulated errors and warnings.  */
+  while ((errtext = ctf_errwarning_next (fp, &it, &is_warning, &err)) != NULL)
+    {
+      non_fatal (_("%s: %s"), is_warning ? _("warning"): _("error"),
+                errtext);
+      free (errtext);
+    }
+  if (err != ECTF_NEXT_END)
+    {
+      non_fatal (_("CTF error: cannot get CTF errors: `%s'"),
+                ctf_errmsg (err));
+    }
+}
+
 /* Dump one CTF archive member.  */
 
 static int
@@ -4096,11 +4135,14 @@ dump_ctf_archive_member (ctf_file_t *ctf, const char *name, void *arg)
 
       if (ctf_errno (ctf))
        {
-         non_fatal (_("Iteration failed: %s, %s\n"), *thing,
+         non_fatal (_("Iteration failed: %s, %s"), *thing,
                   ctf_errmsg (ctf_errno (ctf)));
          break;
        }
     }
+
+  dump_ctf_errs (ctf);
+
   return 0;
 }
 
@@ -4129,7 +4171,8 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
   ctfsect = make_ctfsect (sect_name, ctfdata, ctfsize);
   if ((ctfa = ctf_bfdopen_ctfsect (abfd, &ctfsect, &err)) == NULL)
     {
-      non_fatal (_("CTF open failure: %s\n"), ctf_errmsg (err));
+      dump_ctf_errs (NULL);
+      non_fatal (_("CTF open failure: %s"), ctf_errmsg (err));
       bfd_fatal (bfd_get_filename (abfd));
     }
 
@@ -4138,7 +4181,8 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
       ctfsect = make_ctfsect (parent_name, parentdata, parentsize);
       if ((parenta = ctf_bfdopen_ctfsect (abfd, &ctfsect, &err)) == NULL)
        {
-         non_fatal (_("CTF open failure: %s\n"), ctf_errmsg (err));
+         dump_ctf_errs (NULL);
+         non_fatal (_("CTF open failure: %s"), ctf_errmsg (err));
          bfd_fatal (bfd_get_filename (abfd));
        }
 
@@ -4152,7 +4196,8 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
      put CTFs and their parents in archives together.)  */
   if ((parent = ctf_arc_open_by_name (lookparent, NULL, &err)) == NULL)
     {
-      non_fatal (_("CTF open failure: %s\n"), ctf_errmsg (err));
+      dump_ctf_errs (NULL);
+      non_fatal (_("CTF open failure: %s"), ctf_errmsg (err));
       bfd_fatal (bfd_get_filename (abfd));
     }
 
@@ -4165,6 +4210,11 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
   free (parentdata);
   free (ctfdata);
 }
+#else
+static void
+dump_ctf (bfd *abfd ATTRIBUTE_UNUSED, const char *sect_name ATTRIBUTE_UNUSED,
+         const char *parent_name ATTRIBUTE_UNUSED) {}
+#endif
 
 \f
 static void
@@ -4245,10 +4295,10 @@ dump_section (bfd *abfd, asection *section, void *dummy ATTRIBUTE_UNUSED)
   int count;
   int width;
 
-  if ((section->flags & SEC_HAS_CONTENTS) == 0)
+  if (! process_section_p (section))
     return;
 
-  if (! process_section_p (section))
+  if ((section->flags & SEC_HAS_CONTENTS) == 0)
     return;
 
   if ((datasize = bfd_section_size (section)) == 0)
@@ -5346,6 +5396,7 @@ main (int argc, char **argv)
        case OPTION_DWARF_CHECK:
          dwarf_check = TRUE;
          break;
+#ifdef ENABLE_LIBCTF
        case OPTION_CTF:
          dump_ctf_section_info = TRUE;
          dump_ctf_section_name = xstrdup (optarg);
@@ -5354,6 +5405,7 @@ main (int argc, char **argv)
        case OPTION_CTF_PARENT:
          dump_ctf_parent_name = xstrdup (optarg);
          break;
+#endif
        case 'G':
          dump_stab_section_info = TRUE;
          seenflag = TRUE;