ld testsuite on x86_64 with --enable-shared
[deliverable/binutils-gdb.git] / ld / ldmisc.c
index 319f247e3bec7c42cb02d784138fa8c52c5d9783..8e77f6b2b10069abc492a007bf851c5f320ddb9f 100644 (file)
@@ -1,5 +1,5 @@
 /* ldmisc.c
-   Copyright (C) 1991-2019 Free Software Foundation, Inc.
+   Copyright (C) 1991-2021 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support.
 
    This file is part of the GNU Binutils.
@@ -23,6 +23,7 @@
 #include "bfd.h"
 #include "bfdlink.h"
 #include "libiberty.h"
+#include "ctf-api.h"
 #include "safe-ctype.h"
 #include "filenames.h"
 #include "demangle.h"
@@ -58,6 +59,7 @@
  %pR info about a relent
  %pS print script file and linenumber from etree_type.
  %pT symbol name
+ %pU print script file without linenumber from etree_type.
  %s arbitrary string, like printf
  %u integer, like printf
  %v hex bfd_vma, no leading zeros
@@ -321,6 +323,7 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
                unsigned int linenumber;
                bfd_boolean discard_last;
                bfd_boolean done;
+               bfd_error_type last_bfd_error = bfd_get_error ();
 
                abfd = args[arg_no].reladdr.abfd;
                section = args[arg_no].reladdr.sec;
@@ -373,13 +376,11 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
                                    abfd, functionname);
 
                            last_bfd = abfd;
-                           if (last_file != NULL)
-                             free (last_file);
+                           free (last_file);
                            last_file = NULL;
                            if (filename)
                              last_file = xstrdup (filename);
-                           if (last_function != NULL)
-                             free (last_function);
+                           free (last_function);
                            last_function = xstrdup (functionname);
                          }
                        discard_last = FALSE;
@@ -405,20 +406,15 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
                  }
                if (!done)
                  lfinfo (fp, "(%pA+0x%v)", section, offset);
+               bfd_set_error (last_bfd_error);
 
                if (discard_last)
                  {
                    last_bfd = NULL;
-                   if (last_file != NULL)
-                     {
-                       free (last_file);
-                       last_file = NULL;
-                     }
-                   if (last_function != NULL)
-                     {
-                       free (last_function);
-                       last_function = NULL;
-                     }
+                   free (last_file);
+                   last_file = NULL;
+                   free (last_function);
+                   last_function = NULL;
                  }
              }
              break;
@@ -453,10 +449,11 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
                    fprintf (fp, "%s generated", program_name);
                  else if (abfd->my_archive != NULL
                           && !bfd_is_thin_archive (abfd->my_archive))
-                   fprintf (fp, "%s(%s)", abfd->my_archive->filename,
-                            abfd->filename);
+                   fprintf (fp, "%s(%s)",
+                            bfd_get_filename (abfd->my_archive),
+                            bfd_get_filename (abfd));
                  else
-                   fprintf (fp, "%s", abfd->filename);
+                   fprintf (fp, "%s", bfd_get_filename (abfd));
                }
              else if (*fmt == 'I')
                {
@@ -469,7 +466,8 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
                  if (i->the_bfd != NULL
                      && i->the_bfd->my_archive != NULL
                      && !bfd_is_thin_archive (i->the_bfd->my_archive))
-                   fprintf (fp, "(%s)%s", i->the_bfd->my_archive->filename,
+                   fprintf (fp, "(%s)%s",
+                            bfd_get_filename (i->the_bfd->my_archive),
                             i->local_sym_name);
                  else
                    fprintf (fp, "%s", i->filename);
@@ -486,9 +484,9 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
                          relent->addend,
                          relent->howto->name);
                }
-             else if (*fmt == 'S')
+             else if (*fmt == 'S' || *fmt == 'U')
                {
-                 /* Print script file and linenumber.  */
+                 /* Print script file and perhaps the associated linenumber.  */
                  etree_type node;
                  etree_type *tp = (etree_type *) args[arg_no].p;
 
@@ -500,8 +498,10 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
                      tp->type.filename = ldlex_filename ();
                      tp->type.lineno = lineno;
                    }
-                 if (tp->type.filename != NULL)
+                 if (tp->type.filename != NULL && fmt[-1] == 'S')
                    fprintf (fp, "%s:%u", tp->type.filename, tp->type.lineno);
+                 else if (tp->type.filename != NULL && fmt[-1] == 'U')
+                   fprintf (fp, "%s", tp->type.filename);
                }
              else if (*fmt == 'T')
                {
This page took 0.025171 seconds and 4 git commands to generate.