Use bfd_get_filename throughout binutils
authorAlan Modra <amodra@gmail.com>
Tue, 19 May 2020 03:05:56 +0000 (12:35 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 19 May 2020 03:05:56 +0000 (12:35 +0930)
* ar.c (map_over_members, get_pos_bfd, delete_members, move_members),
(replace_members): Use bfd_get_filename rather than accessing
bfd->filename directly.
* arsup.c (map_over_list, ar_delete, ar_replace, ar_extract): Likewise.
* binemul.c (do_ar_emul_append): Likewise.
* coffgrok.c (coff_grok): Likewise.

binutils/ChangeLog
binutils/ar.c
binutils/arsup.c
binutils/binemul.c
binutils/coffgrok.c

index b2ebe9b55cfdda553ed529ff1bc888ed9970aaf1..bc0c99907bfa9a4825d562940d9aa674cc906858 100644 (file)
@@ -1,3 +1,12 @@
+2020-05-19  Alan Modra  <amodra@gmail.com>
+
+       * ar.c (map_over_members, get_pos_bfd, delete_members, move_members),
+       (replace_members): Use bfd_get_filename rather than accessing
+       bfd->filename directly.
+       * arsup.c (map_over_list, ar_delete, ar_replace, ar_extract): Likewise.
+       * binemul.c (do_ar_emul_append): Likewise.
+       * coffgrok.c (coff_grok): Likewise.
+
 2020-05-18  Stafford Horne  <shorne@gmail.com>
 
        * MAINTAINERS (OR1K): Add myself as maintainer.
index 1057db9980eddc4559ce5d8c253ddf483a29e1f5..85b342a6502768be49dd2b97362dde96957a6099 100644 (file)
@@ -225,7 +225,7 @@ map_over_members (bfd *arch, void (*function)(bfd *), char **files, int count)
          if (head->archive_pass)
            continue;
 
-         filename = head->filename;
+         filename = bfd_get_filename (head);
          if (filename == NULL)
            {
              /* Some archive formats don't get the filenames filled in
@@ -1282,7 +1282,7 @@ get_pos_bfd (bfd **contents, enum pos default_pos, const char *default_posname)
   else
     {
       for (; *after_bfd; after_bfd = &(*after_bfd)->archive_next)
-       if (FILENAME_CMP ((*after_bfd)->filename, realposname) == 0)
+       if (FILENAME_CMP (bfd_get_filename (*after_bfd), realposname) == 0)
          {
            if (realpos == pos_after)
              after_bfd = &(*after_bfd)->archive_next;
@@ -1321,7 +1321,7 @@ delete_members (bfd *arch, char **files_to_delete)
       while (*current_ptr_ptr)
        {
          if (FILENAME_CMP (normalize (*files_to_delete, arch),
-                           (*current_ptr_ptr)->filename) == 0)
+                           bfd_get_filename (*current_ptr_ptr)) == 0)
            {
              ++match_count;
              if (counted_name_mode
@@ -1376,7 +1376,7 @@ move_members (bfd *arch, char **files_to_move)
        {
          bfd *current_ptr = *current_ptr_ptr;
          if (FILENAME_CMP (normalize (*files_to_move, arch),
-                           current_ptr->filename) == 0)
+                           bfd_get_filename (current_ptr)) == 0)
            {
              /* Move this file to the end of the list - first cut from
                 where it is.  */
@@ -1398,7 +1398,8 @@ move_members (bfd *arch, char **files_to_move)
          current_ptr_ptr = &((*current_ptr_ptr)->archive_next);
        }
       /* xgettext:c-format */
-      fatal (_("no entry %s in archive %s!"), *files_to_move, arch->filename);
+      fatal (_("no entry %s in archive %s!"), *files_to_move,
+            bfd_get_filename (arch));
 
     next_file:;
     }
@@ -1428,7 +1429,7 @@ replace_members (bfd *arch, char **files_to_move, bfd_boolean quick)
              /* For compatibility with existing ar programs, we
                 permit the same file to be added multiple times.  */
              if (FILENAME_CMP (normalize (*files_to_move, arch),
-                               normalize (current->filename, arch)) == 0
+                               normalize (bfd_get_filename (current), arch)) == 0
                  && current->arelt_data != NULL)
                {
                  if (newer_only)
@@ -1444,14 +1445,14 @@ replace_members (bfd *arch, char **files_to_move, bfd_boolean quick)
                      if (bfd_stat_arch_elt (current, &asbuf) != 0)
                        /* xgettext:c-format */
                        fatal (_("internal stat error on %s"),
-                              current->filename);
+                              bfd_get_filename (current));
 
                      if (fsbuf.st_mtime <= asbuf.st_mtime)
                        goto next_file;
                    }
 
                  after_bfd = get_pos_bfd (&arch->archive_next, pos_after,
-                                          current->filename);
+                                          bfd_get_filename (current));
                  if (ar_emul_replace (after_bfd, *files_to_move,
                                       target, verbose))
                    {
index 00967c972cd67a1fb83b65d4ced9858bf44defed..a668f270f1a11c3cbc0c77be6419910ece47de7b 100644 (file)
@@ -77,8 +77,8 @@ map_over_list (bfd *arch, void (*function) (bfd *, bfd *), struct list *list)
 
          for (head = arch->archive_next; head; head = head->archive_next)
            {
-             if (head->filename != NULL
-                 && FILENAME_CMP (ptr->name, head->filename) == 0)
+             if (bfd_get_filename (head) != NULL
+                 && FILENAME_CMP (ptr->name, bfd_get_filename (head)) == 0)
                {
                  found = TRUE;
                  function (head, prev);
@@ -311,7 +311,7 @@ ar_delete (struct list *list)
 
          while (member)
            {
-             if (FILENAME_CMP(member->filename, list->name) == 0)
+             if (FILENAME_CMP (bfd_get_filename (member), list->name) == 0)
                {
                  *prev = member->archive_next;
                  found = 1;
@@ -376,7 +376,7 @@ ar_replace (struct list *list)
 
          while (member)
            {
-             if (FILENAME_CMP (member->filename, list->name) == 0)
+             if (FILENAME_CMP (bfd_get_filename (member), list->name) == 0)
                {
                  /* Found the one to replace.  */
                  bfd *abfd = bfd_openr (list->name, NULL);
@@ -474,7 +474,7 @@ ar_extract (struct list *list)
 
          while (member && !found)
            {
-             if (FILENAME_CMP (member->filename, list->name) == 0)
+             if (FILENAME_CMP (bfd_get_filename (member), list->name) == 0)
                {
                  extract_file (member);
                  found = 1;
index c1621c33954588c5c458e71fc69133c7edb3ba1d..7c71b5b78c1a25116862696b7dee536f377e1c7d 100644 (file)
@@ -84,7 +84,7 @@ do_ar_emul_append (bfd **after_bfd, bfd *new_bfd,
   if (!check (new_bfd))
     return FALSE;
 
-  AR_EMUL_APPEND_PRINT_VERBOSE (verbose, new_bfd->filename);
+  AR_EMUL_APPEND_PRINT_VERBOSE (verbose, bfd_get_filename (new_bfd));
 
   new_bfd->archive_next = *after_bfd;
   *after_bfd = new_bfd;
index 74e6a7b68a778caac52d3045bbdbcb38ea573716..eef888ff15191c70da8def0af20ec0133725b3dc 100644 (file)
@@ -890,12 +890,12 @@ coff_grok (bfd *inabfd)
   storage = bfd_get_symtab_upper_bound (abfd);
 
   if (storage < 0)
-    bfd_fatal (abfd->filename);
+    bfd_fatal (bfd_get_filename (abfd));
 
   syms = (asymbol **) xmalloc (storage);
   symcount = bfd_canonicalize_symtab (abfd, syms);
   if (symcount < 0)
-    bfd_fatal (abfd->filename);
+    bfd_fatal (bfd_get_filename (abfd));
   rawsyms = obj_raw_syments (abfd);
   rawcount = obj_raw_syment_count (abfd);
   tindex = (struct coff_symbol **) (xcalloc (sizeof (struct coff_symbol *), rawcount));