gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / binutils / bucomm.c
index 22bf24aeb763c23842a38d5be9ebbfeab922de6a..9e6a02843e6c7ba11545f69a6a31e927d177a9b0 100644 (file)
@@ -1,5 +1,5 @@
 /* bucomm.c -- Bin Utils COMmon code.
-   Copyright (C) 1991-2016 Free Software Foundation, Inc.
+   Copyright (C) 1991-2020 Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
 
@@ -44,8 +44,12 @@ void
 bfd_nonfatal (const char *string)
 {
   const char *errmsg;
+  enum bfd_error err = bfd_get_error ();
 
-  errmsg = bfd_errmsg (bfd_get_error ());
+  if (err == bfd_error_no_error)
+    errmsg = _("cause of error unknown");
+  else
+    errmsg = bfd_errmsg (err);
   fflush (stdout);
   if (string)
     fprintf (stderr, "%s: %s: %s\n", program_name, string, errmsg);
@@ -60,10 +64,10 @@ bfd_nonfatal (const char *string)
    bfd error message is printed.  In summary, error messages are of
    one of the following forms:
 
-   PROGRAM:file: bfd-error-message
-   PROGRAM:file[section]: bfd-error-message
-   PROGRAM:file: printf-message: bfd-error-message
-   PROGRAM:file[section]: printf-message: bfd-error-message.  */
+   PROGRAM: file: bfd-error-message
+   PROGRAM: file[section]: bfd-error-message
+   PROGRAM: file: printf-message: bfd-error-message
+   PROGRAM: file[section]: printf-message: bfd-error-message.  */
 
 void
 bfd_nonfatal_message (const char *filename,
@@ -74,8 +78,12 @@ bfd_nonfatal_message (const char *filename,
   const char *errmsg;
   const char *section_name;
   va_list args;
+  enum bfd_error err = bfd_get_error ();
 
-  errmsg = bfd_errmsg (bfd_get_error ());
+  if (err == bfd_error_no_error)
+    errmsg = _("cause of error unknown");
+  else
+    errmsg = bfd_errmsg (err);
   fflush (stdout);
   section_name = NULL;
   va_start (args, format);
@@ -86,12 +94,12 @@ bfd_nonfatal_message (const char *filename,
       if (!filename)
        filename = bfd_get_archive_filename (abfd);
       if (section)
-       section_name = bfd_get_section_name (abfd, section);
+       section_name = bfd_section_name (section);
     }
   if (section_name)
-    fprintf (stderr, ":%s[%s]", filename, section_name);
+    fprintf (stderr, ": %s[%s]", filename, section_name);
   else
-    fprintf (stderr, ":%s", filename);
+    fprintf (stderr, ": %s", filename);
 
   if (format)
     {
@@ -427,7 +435,7 @@ display_info (void)
    Mode       User\tGroup\tSize\tDate               Name */
 
 void
-print_arelt_descr (FILE *file, bfd *abfd, bfd_boolean verbose)
+print_arelt_descr (FILE *file, bfd *abfd, bfd_boolean verbose, bfd_boolean offsets)
 {
   struct stat buf;
 
@@ -458,7 +466,17 @@ print_arelt_descr (FILE *file, bfd *abfd, bfd_boolean verbose)
        }
     }
 
-  fprintf (file, "%s\n", bfd_get_filename (abfd));
+  fprintf (file, "%s", bfd_get_filename (abfd));
+
+  if (offsets)
+    {
+      if (bfd_is_thin_archive (abfd) && abfd->proxy_origin)
+        fprintf (file, " 0x%lx", (unsigned long) abfd->proxy_origin);
+      else if (!bfd_is_thin_archive (abfd) && abfd->origin)
+        fprintf (file, " 0x%lx", (unsigned long) abfd->origin);
+    }
+
+  fprintf (file, "\n");
 }
 
 /* Return a path for a new temporary file in the same directory
@@ -514,7 +532,7 @@ template_in_dir (const char *path)
    as FILENAME.  */
 
 char *
-make_tempname (char *filename)
+make_tempname (const char *filename)
 {
   char *tmpname = template_in_dir (filename);
   int fd;
@@ -540,7 +558,7 @@ make_tempname (char *filename)
    directory containing FILENAME.  */
 
 char *
-make_tempdir (char *filename)
+make_tempdir (const char *filename)
 {
   char *tmpname = template_in_dir (filename);
 
@@ -587,6 +605,9 @@ get_file_size (const char * file_name)
 {
   struct stat statbuf;
 
+  if (file_name == NULL)
+    return (off_t) -1;
+
   if (stat (file_name, &statbuf) < 0)
     {
       if (errno == ENOENT)
@@ -595,6 +616,8 @@ get_file_size (const char * file_name)
        non_fatal (_("Warning: could not locate '%s'.  reason: %s"),
                   file_name, strerror (errno));
     }
+  else if (S_ISDIR (statbuf.st_mode))
+    non_fatal (_("Warning: '%s' is a directory"), file_name);
   else if (! S_ISREG (statbuf.st_mode))
     non_fatal (_("Warning: '%s' is not an ordinary file"), file_name);
   else if (statbuf.st_size < 0)
This page took 0.029074 seconds and 4 git commands to generate.