]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use bfd_get_filename throughout bfd
authorAlan Modra <amodra@gmail.com>
Tue, 19 May 2020 03:05:03 +0000 (12:35 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 19 May 2020 03:05:03 +0000 (12:35 +0930)
* aix5ppc-core.c (xcoff64_core_file_matches_executable_p): Use
bfd_get_filename rather than accessing bfd->filename directly.
* aout-target.h (MY (object_p)): Likewise.
* aoutx.h (aout_find_nearest_line, aout_link_write_symbols): Likewise.
* archive.c (find_nested_archive, _bfd_generic_read_ar_hdr_mag),
(_bfd_construct_extended_name_table, _bfd_bsd44_write_ar_hdr),
(_bfd_archive_bsd44_construct_extended_name_table),
(_bfd_write_archive_contents, _bfd_compute_and_write_armap),
(_bfd_bsd_write_armap): Likewise.
* bfd.c (bfd_errmsg, _bfd_doprnt): Likewise.
* cache.c (bfd_open_file): Likewise.
* ecoff.c (_bfd_ecoff_write_armap): Likewise.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Likewise.
* elf32-bfin.c (bfinfdpic_relocate_section): Likewise.
* elf32-frv.c (elf32_frv_relocate_section): Likewise.
* elf32-hppa.c (elf32_hppa_final_link): Likewise.
* elf32-nds32.c (nds32_elf_output_symbol_hook),
(patch_tls_desc_to_ie): Likewise.
* elf32-spu.c (sort_bfds, print_one_overlay_section),
(spu_elf_auto_overlay): Likewise.
* elf64-hppa.c (elf_hppa_final_link): Likewise.
* elf64-ia64-vms.c (elf64_ia64_size_dynamic_sections): Likewise.
* elfcore.h (elf_core_file_matches_executable_p): Likewise.
* elflink.c (bfd_elf_size_dynamic_sections),
(elf_link_input_bfd): Likewise.
* linker.c (_bfd_generic_link_output_symbols): Likewise.
* mach-o.c (bfd_mach_o_follow_dsym),
(bfd_mach_o_close_and_cleanup): Likewise.
* opncls.c (_bfd_delete_bfd, _maybe_make_executable),
(find_separate_debug_file, get_build_id_name): Likewise.
* pdp11.c (aout_find_nearest_line, aout_link_write_symbols): Likewise.
* plugin.c (bfd_plugin_open_input): Likewise.
* rs6000-core.c (rs6000coff_core_file_matches_executable_p): Likewise.
* som.c (som_write_armap): Likewise.
* srec.c (srec_write_record, srec_write_symbols): Likewise.
* vms-lib.c (_bfd_vms_lib_get_imagelib_file),
(_bfd_vms_lib_write_archive_contents): Likewise.
* xcofflink.c (xcoff_link_add_dynamic_symbols): Likewise.

28 files changed:
bfd/ChangeLog
bfd/aix5ppc-core.c
bfd/aout-target.h
bfd/aoutx.h
bfd/archive.c
bfd/bfd.c
bfd/cache.c
bfd/ecoff.c
bfd/ecofflink.c
bfd/elf32-bfin.c
bfd/elf32-frv.c
bfd/elf32-hppa.c
bfd/elf32-nds32.c
bfd/elf32-spu.c
bfd/elf64-hppa.c
bfd/elf64-ia64-vms.c
bfd/elfcore.h
bfd/elflink.c
bfd/linker.c
bfd/mach-o.c
bfd/opncls.c
bfd/pdp11.c
bfd/plugin.c
bfd/rs6000-core.c
bfd/som.c
bfd/srec.c
bfd/vms-lib.c
bfd/xcofflink.c

index 3926bd1005ba7ee66b01850a525fb6e03b689b2a..d9892235721b13537f30dcbeeb8ccb2785a56ee0 100644 (file)
@@ -1,3 +1,44 @@
+2020-05-19  Alan Modra  <amodra@gmail.com>
+
+       * aix5ppc-core.c (xcoff64_core_file_matches_executable_p): Use
+       bfd_get_filename rather than accessing bfd->filename directly.
+       * aout-target.h (MY (object_p)): Likewise.
+       * aoutx.h (aout_find_nearest_line, aout_link_write_symbols): Likewise.
+       * archive.c (find_nested_archive, _bfd_generic_read_ar_hdr_mag),
+       (_bfd_construct_extended_name_table, _bfd_bsd44_write_ar_hdr),
+       (_bfd_archive_bsd44_construct_extended_name_table),
+       (_bfd_write_archive_contents, _bfd_compute_and_write_armap),
+       (_bfd_bsd_write_armap): Likewise.
+       * bfd.c (bfd_errmsg, _bfd_doprnt): Likewise.
+       * cache.c (bfd_open_file): Likewise.
+       * ecoff.c (_bfd_ecoff_write_armap): Likewise.
+       * ecofflink.c (bfd_ecoff_debug_accumulate_other): Likewise.
+       * elf32-bfin.c (bfinfdpic_relocate_section): Likewise.
+       * elf32-frv.c (elf32_frv_relocate_section): Likewise.
+       * elf32-hppa.c (elf32_hppa_final_link): Likewise.
+       * elf32-nds32.c (nds32_elf_output_symbol_hook),
+       (patch_tls_desc_to_ie): Likewise.
+       * elf32-spu.c (sort_bfds, print_one_overlay_section),
+       (spu_elf_auto_overlay): Likewise.
+       * elf64-hppa.c (elf_hppa_final_link): Likewise.
+       * elf64-ia64-vms.c (elf64_ia64_size_dynamic_sections): Likewise.
+       * elfcore.h (elf_core_file_matches_executable_p): Likewise.
+       * elflink.c (bfd_elf_size_dynamic_sections),
+       (elf_link_input_bfd): Likewise.
+       * linker.c (_bfd_generic_link_output_symbols): Likewise.
+       * mach-o.c (bfd_mach_o_follow_dsym),
+       (bfd_mach_o_close_and_cleanup): Likewise.
+       * opncls.c (_bfd_delete_bfd, _maybe_make_executable),
+       (find_separate_debug_file, get_build_id_name): Likewise.
+       * pdp11.c (aout_find_nearest_line, aout_link_write_symbols): Likewise.
+       * plugin.c (bfd_plugin_open_input): Likewise.
+       * rs6000-core.c (rs6000coff_core_file_matches_executable_p): Likewise.
+       * som.c (som_write_armap): Likewise.
+       * srec.c (srec_write_record, srec_write_symbols): Likewise.
+       * vms-lib.c (_bfd_vms_lib_get_imagelib_file),
+       (_bfd_vms_lib_write_archive_contents): Likewise.
+       * xcofflink.c (xcoff_link_add_dynamic_symbols): Likewise.
+
 2020-05-19  Alan Modra  <amodra@gmail.com>
 
        PR 25713
index cddb647de13955a1c14ed769cc58681c6e6ddd1b..ba8a4e0524082994bde27078a91d94ef1f406045 100644 (file)
@@ -288,11 +288,11 @@ xcoff64_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
     }
 
   str1 = strrchr (path, '/');
-  str2 = strrchr (exec_bfd->filename, '/');
+  str2 = strrchr (bfd_get_filename (exec_bfd), '/');
 
   /* Step over character '/'.  */
   str1 = str1 != NULL ? str1 + 1 : path;
-  str2 = str2 != NULL ? str2 + 1 : exec_bfd->filename;
+  str2 = str2 != NULL ? str2 + 1 : bfd_get_filename (exec_bfd);
 
   if (strcmp (str1, str2) == 0)
     return_value = TRUE;
index 365202e0ce3364d22a1ef647c413d94921af54f8..214c4c5a4917aba3db99eb26ef0dda356fc57c3d 100644 (file)
@@ -180,7 +180,8 @@ MY (object_p) (bfd *abfd)
 #ifndef S_IXUSR
 #define S_IXUSR 0100   /* Execute by owner.  */
 #endif
-      if (stat (abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
+      if (stat (bfd_get_filename (abfd), &buf) == 0
+         && (buf.st_mode & S_IXUSR) != 0)
        abfd->flags |= EXEC_P;
     }
 #endif /* ENTRY_CAN_BE_ZERO */
index 9ffb3fe8610ec2bb63fd8c0454bbb7e4c7afe126..4cf5713c355fc3c6b9d6dfee627d759de8a043fb 100644 (file)
@@ -2686,7 +2686,7 @@ NAME (aout, find_nearest_line) (bfd *abfd,
   bfd_size_type filelen, funclen;
   char *buf;
 
-  *filename_ptr = abfd->filename;
+  *filename_ptr = bfd_get_filename (abfd);
   *functionname_ptr = NULL;
   *line_ptr = 0;
   if (disriminator_ptr)
@@ -4846,7 +4846,8 @@ aout_link_write_symbols (struct aout_final_link_info *flaginfo, bfd *input_bfd)
      discarding such symbols.  */
   if (strip != strip_all
       && (strip != strip_some
-         || bfd_hash_lookup (flaginfo->info->keep_hash, input_bfd->filename,
+         || bfd_hash_lookup (flaginfo->info->keep_hash,
+                             bfd_get_filename (input_bfd),
                              FALSE, FALSE) != NULL)
       && discard != discard_all)
     {
@@ -4854,7 +4855,7 @@ aout_link_write_symbols (struct aout_final_link_info *flaginfo, bfd *input_bfd)
       H_PUT_8 (output_bfd, 0, outsym->e_other);
       H_PUT_16 (output_bfd, 0, outsym->e_desc);
       strtab_index = add_to_stringtab (output_bfd, flaginfo->strtab,
-                                      input_bfd->filename, FALSE);
+                                      bfd_get_filename (input_bfd), FALSE);
       if (strtab_index == (bfd_size_type) -1)
        return FALSE;
       PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
index 3423a336956a211eb707d0f2bff724e52ca6b12c..ff64727c44801e1f37d7eacbf8bbd8a0afdfec49 100644 (file)
@@ -403,7 +403,7 @@ find_nested_archive (const char *filename, bfd *arch_bfd)
   bfd *abfd;
 
   /* PR 15140: Don't allow a nested archive pointing to itself.  */
-  if (filename_cmp (filename, arch_bfd->filename) == 0)
+  if (filename_cmp (filename, bfd_get_filename (arch_bfd)) == 0)
     {
       bfd_set_error (bfd_error_malformed_archive);
       return NULL;
@@ -413,7 +413,7 @@ find_nested_archive (const char *filename, bfd *arch_bfd)
        abfd != NULL;
        abfd = abfd->archive_next)
     {
-      if (filename_cmp (filename, abfd->filename) == 0)
+      if (filename_cmp (filename, bfd_get_filename (abfd)) == 0)
        return abfd;
     }
   abfd = open_nested_file (filename, arch_bfd);
@@ -628,7 +628,7 @@ _bfd_generic_read_ar_hdr_mag (bfd *abfd, const char *mag)
 char *
 _bfd_append_relative_path (bfd *arch, char *elt_name)
 {
-  const char *arch_name = arch->filename;
+  const char *arch_name = bfd_get_filename (arch);
   const char *base_name = lbasename (arch_name);
   size_t prefix_len;
   char *filename;
@@ -1564,13 +1564,13 @@ _bfd_construct_extended_name_table (bfd *abfd,
 
       if (bfd_is_thin_archive (abfd))
        {
-         const char *filename = current->filename;
+         const char *filename = bfd_get_filename (current);
 
          /* If the element being added is a member of another archive
             (i.e., we are flattening), use the containing archive's name.  */
          if (current->my_archive
              && ! bfd_is_thin_archive (current->my_archive))
-           filename = current->my_archive->filename;
+           filename = bfd_get_filename (current->my_archive);
 
          /* If the path is the same as the previous path seen,
             reuse it.  This can happen when flattening a thin
@@ -1583,8 +1583,8 @@ _bfd_construct_extended_name_table (bfd *abfd,
          /* If the path is relative, adjust it relative to
             the containing archive. */
          if (! IS_ABSOLUTE_PATH (filename)
-             && ! IS_ABSOLUTE_PATH (abfd->filename))
-           normal = adjust_relative_path (filename, abfd->filename);
+             && ! IS_ABSOLUTE_PATH (bfd_get_filename (abfd)))
+           normal = adjust_relative_path (filename, bfd_get_filename (abfd));
          else
            normal = filename;
 
@@ -1598,7 +1598,7 @@ _bfd_construct_extended_name_table (bfd *abfd,
          continue;
        }
 
-      normal = normalize (abfd, current->filename);
+      normal = normalize (abfd, bfd_get_filename (current));
       if (normal == NULL)
        return FALSE;
 
@@ -1655,7 +1655,7 @@ _bfd_construct_extended_name_table (bfd *abfd,
       const char *normal;
       unsigned int thislen;
       long stroff;
-      const char *filename = current->filename;
+      const char *filename = bfd_get_filename (current);
 
       if (bfd_is_thin_archive (abfd))
        {
@@ -1663,7 +1663,7 @@ _bfd_construct_extended_name_table (bfd *abfd,
             (i.e., we are flattening), use the containing archive's name.  */
          if (current->my_archive
              && ! bfd_is_thin_archive (current->my_archive))
-           filename = current->my_archive->filename;
+           filename = bfd_get_filename (current->my_archive);
          /* If the path is the same as the previous path seen,
             reuse it.  This can happen when flattening a thin
             archive that contains other archives.
@@ -1672,8 +1672,8 @@ _bfd_construct_extended_name_table (bfd *abfd,
          if (last_filename && filename_cmp (last_filename, filename) == 0)
            normal = last_filename;
          else if (! IS_ABSOLUTE_PATH (filename)
-                  && ! IS_ABSOLUTE_PATH (abfd->filename))
-           normal = adjust_relative_path (filename, abfd->filename);
+                  && ! IS_ABSOLUTE_PATH (bfd_get_filename (abfd)))
+           normal = adjust_relative_path (filename, bfd_get_filename (abfd));
          else
            normal = filename;
        }
@@ -1741,7 +1741,7 @@ _bfd_archive_bsd44_construct_extended_name_table (bfd *abfd,
        current != NULL;
        current = current->archive_next)
     {
-      const char *normal = normalize (abfd, current->filename);
+      const char *normal = normalize (abfd, bfd_get_filename (current));
       int has_space = 0;
       unsigned int len;
 
@@ -1787,7 +1787,7 @@ _bfd_bsd44_write_ar_hdr (bfd *archive, bfd *abfd)
   if (is_bsd44_extended_name (hdr->ar_name))
     {
       /* This is a BSD 4.4 extended name.  */
-      const char *fullname = normalize (abfd, abfd->filename);
+      const char *fullname = normalize (abfd, bfd_get_filename (abfd));
       unsigned int len = strlen (fullname);
       unsigned int padded_len = (len + 3) & ~3;
 
@@ -2139,13 +2139,15 @@ _bfd_write_archive_contents (bfd *arch)
       if (!current->arelt_data)
        {
          current->arelt_data =
-           bfd_ar_hdr_from_filesystem (arch, current->filename, current);
+           bfd_ar_hdr_from_filesystem (arch, bfd_get_filename (current),
+                                       current);
          if (!current->arelt_data)
            goto input_err;
 
          /* Put in the file name.  */
          BFD_SEND (arch, _bfd_truncate_arname,
-                   (arch, current->filename, (char *) arch_hdr (current)));
+                   (arch, bfd_get_filename (current),
+                    (char *) arch_hdr (current)));
        }
 
       if (makemap && ! hasobjects)
@@ -2294,7 +2296,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
 
   /* Drop all the files called __.SYMDEF, we're going to make our own.  */
   while (arch->archive_head
-        && strcmp (arch->archive_head->filename, "__.SYMDEF") == 0)
+        && strcmp (bfd_get_filename (arch->archive_head), "__.SYMDEF") == 0)
     arch->archive_head = arch->archive_head->archive_next;
 
   /* Map over each element.  */
@@ -2495,7 +2497,7 @@ _bfd_bsd_write_armap (bfd *arch,
     {
       struct stat statbuf;
 
-      if (stat (arch->filename, &statbuf) == 0)
+      if (stat (bfd_get_filename (arch), &statbuf) == 0)
        bfd_ardata (arch)->armap_timestamp = (statbuf.st_mtime
                                              + ARMAP_TIME_OFFSET);
       uid = getuid();
index 3aed9be2373ac2ac2abd04544c72b14a7a10b7f3..84e74a36b838599d5b9e911d449e9892cd34972a 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -787,8 +787,8 @@ bfd_errmsg (bfd_error_type error_tag)
       char *buf;
       const char *msg = bfd_errmsg (input_error);
 
-      if (asprintf (&buf, _(bfd_errmsgs [error_tag]), input_bfd->filename, msg)
-         != -1)
+      if (asprintf (&buf, _(bfd_errmsgs [error_tag]),
+                   bfd_get_filename (input_bfd), msg) != -1)
        return buf;
 
       /* Ick, what to do on out of memory?  */
@@ -1114,10 +1114,10 @@ _bfd_doprnt (FILE *stream, const char *format, union _bfd_doprnt_args *args)
                  else if (abfd->my_archive
                           && !bfd_is_thin_archive (abfd->my_archive))
                    result = fprintf (stream, "%s(%s)",
-                                     abfd->my_archive->filename,
-                                     abfd->filename);
+                                     bfd_get_filename (abfd->my_archive),
+                                     bfd_get_filename (abfd));
                  else
-                   result = fprintf (stream, "%s", abfd->filename);
+                   result = fprintf (stream, "%s", bfd_get_filename (abfd));
                }
              else
                PRINT_TYPE (void *, p);
index ed73c161d2c65404e82f20478cd5cdcb2e361195..93abff33fe21006d3d0d4b707ac5f02c5bc39089 100644 (file)
@@ -592,15 +592,17 @@ bfd_open_file (bfd *abfd)
     {
     case read_direction:
     case no_direction:
-      abfd->iostream = _bfd_real_fopen (abfd->filename, FOPEN_RB);
+      abfd->iostream = _bfd_real_fopen (bfd_get_filename (abfd), FOPEN_RB);
       break;
     case both_direction:
     case write_direction:
       if (abfd->opened_once)
        {
-         abfd->iostream = _bfd_real_fopen (abfd->filename, FOPEN_RUB);
+         abfd->iostream = _bfd_real_fopen (bfd_get_filename (abfd),
+                                           FOPEN_RUB);
          if (abfd->iostream == NULL)
-           abfd->iostream = _bfd_real_fopen (abfd->filename, FOPEN_WUB);
+           abfd->iostream = _bfd_real_fopen (bfd_get_filename (abfd),
+                                             FOPEN_WUB);
        }
       else
        {
@@ -627,10 +629,11 @@ bfd_open_file (bfd *abfd)
             the --info option.  */
          struct stat s;
 
-         if (stat (abfd->filename, &s) == 0 && s.st_size != 0)
-           unlink_if_ordinary (abfd->filename);
+         if (stat (bfd_get_filename (abfd), &s) == 0 && s.st_size != 0)
+           unlink_if_ordinary (bfd_get_filename (abfd));
 #endif
-         abfd->iostream = _bfd_real_fopen (abfd->filename, FOPEN_WUB);
+         abfd->iostream = _bfd_real_fopen (bfd_get_filename (abfd),
+                                           FOPEN_WUB);
          abfd->opened_once = TRUE;
        }
       break;
index 82267a889df6ee880cbf0231e90609074abaeab3..1b0d4233e76be17583ddb8ba383c6406a6b86624 100644 (file)
@@ -3106,7 +3106,7 @@ _bfd_ecoff_write_armap (bfd *abfd,
      complain that the index is out of date.  Actually, the Ultrix
      linker just checks the archive name; the GNU linker may check the
      date.  */
-  stat (abfd->filename, &statbuf);
+  stat (bfd_get_filename (abfd), &statbuf);
   _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
                    (long) (statbuf.st_mtime + 60));
 
index ba2bbbc868a78e095025725cc297e9c4df662d6d..dde5593636acd91acc0afb0590160dd282858296 100644 (file)
@@ -1112,7 +1112,7 @@ bfd_ecoff_debug_accumulate_other (void * handle,
   fdr.issBase = output_symhdr->issMax;
   fdr.cbSs = 0;
   fdr.rss = ecoff_add_string (ainfo, info, output_debug, &fdr,
-                             input_bfd->filename);
+                             bfd_get_filename (input_bfd));
   if (fdr.rss == -1)
     return FALSE;
   fdr.isymBase = output_symhdr->isymMax;
index e6383a782ff6c7a0c5bb525a9b0c119e5fbc4682..a51a8e8e9f2d9fdf5dc31ca57f3c3654e2ba4063 100644 (file)
@@ -3015,11 +3015,11 @@ bfinfdpic_relocate_section (bfd * output_bfd,
             input file basename is crt0.o only once.  */
          if (silence_segment_error == 1)
            silence_segment_error =
-             (strlen (input_bfd->filename) == 6
-              && filename_cmp (input_bfd->filename, "crt0.o") == 0)
-             || (strlen (input_bfd->filename) > 6
-                 && filename_cmp (input_bfd->filename
-                                  + strlen (input_bfd->filename) - 7,
+             (strlen (bfd_get_filename (input_bfd)) == 6
+              && filename_cmp (bfd_get_filename (input_bfd), "crt0.o") == 0)
+             || (strlen (bfd_get_filename (input_bfd)) > 6
+                 && filename_cmp (bfd_get_filename (input_bfd)
+                                  + strlen (bfd_get_filename (input_bfd)) - 7,
                             "/crt0.o") == 0)
              ? -1 : 0;
 #endif
index d2a18fd564a92766e8179c8bdc5467a47d3264a3..51ea8fa27ed3e4493caa99a94a7eb2fb1282cb51 100644 (file)
@@ -3896,11 +3896,11 @@ elf32_frv_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
             input file basename is crt0.o only once.  */
          if (silence_segment_error == 1)
            silence_segment_error =
-             (strlen (input_bfd->filename) == 6
-              && filename_cmp (input_bfd->filename, "crt0.o") == 0)
-             || (strlen (input_bfd->filename) > 6
-                 && filename_cmp (input_bfd->filename
-                                  + strlen (input_bfd->filename) - 7,
+             (strlen (bfd_get_filename (input_bfd)) == 6
+              && filename_cmp (bfd_get_filename (input_bfd), "crt0.o") == 0)
+             || (strlen (bfd_get_filename (input_bfd)) > 6
+                 && filename_cmp (bfd_get_filename (input_bfd)
+                                  + strlen (bfd_get_filename (input_bfd)) - 7,
                             "/crt0.o") == 0)
              ? -1 : 0;
          if (!silence_segment_error
index 6d5382dc26de4a0d9300f80dbebc295e410dd5ca..4b76f941adf9d2832d7e7ea75135a7d3350e08fd 100644 (file)
@@ -3196,7 +3196,7 @@ elf32_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
   /* Do not attempt to sort non-regular files.  This is here
      especially for configure scripts and kernel builds which run
      tests with "ld [...] -o /dev/null".  */
-  if (stat (abfd->filename, &buf) != 0
+  if (stat (bfd_get_filename (abfd), &buf) != 0
       || !S_ISREG(buf.st_mode))
     return TRUE;
 
index 6b0b813af0bf3521e1c6bfdba61e4af7dc3c630a..a5a681a946d53d51726850c711da57fa29a32d4f 100644 (file)
@@ -4862,7 +4862,7 @@ nds32_elf_output_symbol_hook (struct bfd_link_info *info,
       if (bfd_is_const_section (input_sec))
        source = input_sec->name;
       else
-       source = input_sec->owner->filename;
+       source = bfd_get_filename (input_sec->owner);
 
       fprintf (sym_ld_script, "\t%s = 0x%08lx;\t /* %s */\n",
               h->root.root.string,
@@ -5047,7 +5047,7 @@ patch_tls_desc_to_ie (bfd_byte *contents, Elf_Internal_Rela *rel, bfd *ibfd)
 
   if (!rz)
     {
-      printf ("%s: %s @ 0x%08x\n", __func__, ibfd->filename,
+      printf ("%s: %s @ 0x%08x\n", __func__, bfd_get_filename (ibfd),
              (int) rel->r_offset);
       BFD_ASSERT(0); /* Unsupported pattern.  */
     }
index 983989081aeb755edaead2456cfc1a93f561af91..193438c7979e1b523cb10fd88251a1996167995e 100644 (file)
@@ -4103,7 +4103,7 @@ sort_bfds (const void *a, const void *b)
   bfd *const *abfd1 = a;
   bfd *const *abfd2 = b;
 
-  return filename_cmp ((*abfd1)->filename, (*abfd2)->filename);
+  return filename_cmp (bfd_get_filename (*abfd1), bfd_get_filename (*abfd2));
 }
 
 static unsigned int
@@ -4123,9 +4123,9 @@ print_one_overlay_section (FILE *script,
 
       if (fprintf (script, "   %s%c%s (%s)\n",
                   (sec->owner->my_archive != NULL
-                   ? sec->owner->my_archive->filename : ""),
+                   ? bfd_get_filename (sec->owner->my_archive) : ""),
                   info->path_separator,
-                  sec->owner->filename,
+                  bfd_get_filename (sec->owner),
                   sec->name) <= 0)
        return -1;
       if (sec->segment_mark)
@@ -4137,9 +4137,9 @@ print_one_overlay_section (FILE *script,
              sec = call_fun->sec;
              if (fprintf (script, "   %s%c%s (%s)\n",
                           (sec->owner->my_archive != NULL
-                           ? sec->owner->my_archive->filename : ""),
+                           ? bfd_get_filename (sec->owner->my_archive) : ""),
                           info->path_separator,
-                          sec->owner->filename,
+                          bfd_get_filename (sec->owner),
                           sec->name) <= 0)
                return -1;
              for (call = call_fun->call_list; call; call = call->next)
@@ -4155,9 +4155,9 @@ print_one_overlay_section (FILE *script,
       if (sec != NULL
          && fprintf (script, "   %s%c%s (%s)\n",
                      (sec->owner->my_archive != NULL
-                      ? sec->owner->my_archive->filename : ""),
+                      ? bfd_get_filename (sec->owner->my_archive) : ""),
                      info->path_separator,
-                     sec->owner->filename,
+                     bfd_get_filename (sec->owner),
                      sec->name) <= 0)
        return -1;
 
@@ -4172,9 +4172,9 @@ print_one_overlay_section (FILE *script,
              if (sec != NULL
                  && fprintf (script, "   %s%c%s (%s)\n",
                              (sec->owner->my_archive != NULL
-                              ? sec->owner->my_archive->filename : ""),
+                              ? bfd_get_filename (sec->owner->my_archive) : ""),
                              info->path_separator,
-                             sec->owner->filename,
+                             bfd_get_filename (sec->owner),
                              sec->name) <= 0)
                return -1;
              for (call = call_fun->call_list; call; call = call->next)
@@ -4335,18 +4335,19 @@ spu_elf_auto_overlay (struct bfd_link_info *info)
 
       qsort (bfd_arr, bfd_count, sizeof (*bfd_arr), sort_bfds);
       for (i = 1; i < bfd_count; ++i)
-       if (filename_cmp (bfd_arr[i - 1]->filename, bfd_arr[i]->filename) == 0)
+       if (filename_cmp (bfd_get_filename (bfd_arr[i - 1]),
+                         bfd_get_filename (bfd_arr[i])) == 0)
          {
            if (bfd_arr[i - 1]->my_archive == bfd_arr[i]->my_archive)
              {
                if (bfd_arr[i - 1]->my_archive && bfd_arr[i]->my_archive)
                  /* xgettext:c-format */
                  info->callbacks->einfo (_("%s duplicated in %s\n"),
-                                         bfd_arr[i]->filename,
-                                         bfd_arr[i]->my_archive->filename);
+                                         bfd_get_filename (bfd_arr[i]),
+                                         bfd_get_filename (bfd_arr[i]->my_archive));
                else
                  info->callbacks->einfo (_("%s duplicated\n"),
-                                         bfd_arr[i]->filename);
+                                         bfd_get_filename (bfd_arr[i]));
                ok = FALSE;
              }
          }
index ae50b2cd4786b030d91d7b5872c6522eb002def1..0fdbea45cce5e8cf9912d5e3b441c91c23f53ff0 100644 (file)
@@ -3040,7 +3040,7 @@ elf_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
   /* Do not attempt to sort non-regular files.  This is here
      especially for configure scripts and kernel builds which run
      tests with "ld [...] -o /dev/null".  */
-  if (stat (abfd->filename, &buf) != 0
+  if (stat (bfd_get_filename (abfd), &buf) != 0
       || !S_ISREG(buf.st_mode))
     return TRUE;
 
index 159698fa07fe3e46ccb693bdfa48afa63d250a26..6fa116f610eea6cd59e36f8e94cfca8f9e495f59 100644 (file)
@@ -2844,7 +2844,7 @@ elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
                                           elf_ia64_vms_ident (abfd)))
            return FALSE;
 
-         soname = vms_get_module_name (abfd->filename, TRUE);
+         soname = vms_get_module_name (bfd_get_filename (abfd), TRUE);
          if (soname == NULL)
            return FALSE;
          strindex = dynstrsec->size;
index 44707ebb60fbd7659693fcffd06ef0064c4cc42f..0339a671fc7fdb7371d3771581870a107ec00eeb 100644 (file)
@@ -61,9 +61,9 @@ elf_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
   corename = elf_tdata (core_bfd)->core->program;
   if (corename != NULL)
     {
-      const char* execname = strrchr (exec_bfd->filename, '/');
+      const char* execname = strrchr (bfd_get_filename (exec_bfd), '/');
 
-      execname = execname ? execname + 1 : exec_bfd->filename;
+      execname = execname ? execname + 1 : bfd_get_filename (exec_bfd);
 
       if (strcmp (execname, corename) != 0)
        return FALSE;
index 6624864bf540bd1bedc2c14b9950d52a33da9a21..90ada7a1cca0142a2dec682b11d1babd4fd91d82 100644 (file)
@@ -6623,7 +6623,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
            {
              size_t indx;
 
-             name = lbasename (output_bfd->filename);
+             name = lbasename (bfd_get_filename (output_bfd));
              def.vd_hash = bfd_elf_hash (name);
              indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
                                          name, FALSE);
@@ -6850,7 +6850,8 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
              indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
                                          elf_dt_name (vn->vn_bfd) != NULL
                                          ? elf_dt_name (vn->vn_bfd)
-                                         : lbasename (vn->vn_bfd->filename),
+                                         : lbasename (bfd_get_filename
+                                                      (vn->vn_bfd)),
                                          FALSE);
              if (indx == (size_t) -1)
                return FALSE;
@@ -10675,7 +10676,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
        {
          _bfd_error_handler (_("warning: --enable-non-contiguous-regions "
                                "discards section `%s' from '%s'\n"),
-                             isec->name, isec->owner->filename);
+                             isec->name, bfd_get_filename (isec->owner));
          continue;
        }
 
@@ -10726,7 +10727,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
          osym.st_shndx = SHN_ABS;
          if (!elf_link_output_symstrtab (flinfo,
                                          (input_bfd->lto_output ? NULL
-                                          : input_bfd->filename),
+                                          : bfd_get_filename (input_bfd)),
                                          &osym, bfd_abs_section_ptr,
                                          NULL))
            return FALSE;
@@ -11028,7 +11029,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
 #ifdef DEBUG
                  printf ("Encountered a complex symbol!");
                  printf (" (input_bfd %s, section %s, reloc %ld\n",
-                         input_bfd->filename, o->name,
+                         bfd_get_filename (input_bfd), o->name,
                          (long) (rel - internal_relocs));
                  printf (" symbol: idx  %8.8lx, name %s\n",
                          r_symndx, sym_name);
index c523f8b5c649730c04cedbbe8cb8da0cd8805f86..3820ce14f83a7b2f591d8b7b0ee9dfa0025791f5 100644 (file)
@@ -1995,7 +1995,7 @@ _bfd_generic_link_output_symbols (bfd *output_bfd,
              newsym = bfd_make_empty_symbol (input_bfd);
              if (!newsym)
                return FALSE;
-             newsym->name = input_bfd->filename;
+             newsym->name = bfd_get_filename (input_bfd);
              newsym->value = 0;
              newsym->flags = BSF_LOCAL | BSF_FILE;
              newsym->section = sec;
index ee58a7adfae1375468c9dee6beb0ef450ab0922f..33bd81e121eb0483dd90d8ef3088f455eff41b1f 100644 (file)
@@ -6075,12 +6075,12 @@ bfd_mach_o_follow_dsym (bfd *abfd)
   if (abfd->my_archive && !bfd_is_thin_archive (abfd->my_archive))
     base_bfd = abfd->my_archive;
   /* BFD may have been opened from a stream. */
-  if (base_bfd->filename == NULL)
+  if (bfd_get_filename (base_bfd) == NULL)
     {
       bfd_set_error (bfd_error_invalid_operation);
       return NULL;
     }
-  base_basename = lbasename (base_bfd->filename);
+  base_basename = lbasename (bfd_get_filename (base_bfd));
 
   uuid_cmd = bfd_mach_o_lookup_uuid_command (abfd);
   if (uuid_cmd == NULL)
@@ -6090,14 +6090,14 @@ bfd_mach_o_follow_dsym (bfd *abfd)
      It seems apple's GDB checks all files in the dSYM bundle directory.
      http://opensource.apple.com/source/gdb/gdb-1708/src/gdb/macosx/macosx-tdep.c
   */
-  dsym_filename = (char *)bfd_malloc (strlen (base_bfd->filename)
+  dsym_filename = (char *)bfd_malloc (strlen (bfd_get_filename (base_bfd))
                                       + strlen (dsym_subdir) + 1
                                       + strlen (base_basename) + 1);
   if (dsym_filename == NULL)
     return NULL;
 
   sprintf (dsym_filename, "%s%s/%s",
-          base_bfd->filename, dsym_subdir, base_basename);
+          bfd_get_filename (base_bfd), dsym_subdir, base_basename);
 
   dsym_bfd = bfd_mach_o_find_dsym (dsym_filename, uuid_cmd,
                                   bfd_get_arch_info (abfd));
@@ -6175,8 +6175,8 @@ bfd_mach_o_close_and_cleanup (bfd *abfd)
             but it is small, and happens when we are closing down, so it
             should not matter too much.  */
          char *dsym_filename = (char *)(fat_bfd
-                                        ? fat_bfd->filename
-                                        : mdata->dsym_bfd->filename);
+                                        ? bfd_get_filename (fat_bfd)
+                                        : bfd_get_filename (mdata->dsym_bfd));
 #endif
          bfd_close (mdata->dsym_bfd);
          mdata->dsym_bfd = NULL;
index 99097a9e39989e377af70e9450a970b009439e70..5d3437d38225b7c9b47299adfa87a9d5b6bc02bb 100644 (file)
@@ -126,8 +126,7 @@ _bfd_delete_bfd (bfd *abfd)
       objalloc_free ((struct objalloc *) abfd->memory);
     }
 
-  if (abfd->filename)
-    free ((char *) abfd->filename);
+  free ((char *) bfd_get_filename (abfd));
   free (abfd->arelt_data);
   free (abfd);
 }
@@ -709,7 +708,7 @@ _maybe_make_executable (bfd * abfd)
     {
       struct stat buf;
 
-      if (stat (abfd->filename, &buf) == 0
+      if (stat (bfd_get_filename (abfd), &buf) == 0
          /* Do not attempt to change non-regular files.  This is
             here especially for configure scripts and kernel builds
             which run tests with "ld [...] -o /dev/null".  */
@@ -718,7 +717,7 @@ _maybe_make_executable (bfd * abfd)
          unsigned int mask = umask (0);
 
          umask (mask);
-         chmod (abfd->filename,
+         chmod (bfd_get_filename (abfd),
                 (0777
                  & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
        }
@@ -1400,7 +1399,7 @@ find_separate_debug_file (bfd *             abfd,
     debug_file_directory = ".";
 
   /* BFD may have been opened from a stream.  */
-  if (abfd->filename == NULL)
+  if (bfd_get_filename (abfd) == NULL)
     {
       bfd_set_error (bfd_error_invalid_operation);
       return NULL;
@@ -1420,8 +1419,9 @@ find_separate_debug_file (bfd *             abfd,
 
   if (include_dirs)
     {
-      for (dirlen = strlen (abfd->filename); dirlen > 0; dirlen--)
-       if (IS_DIR_SEPARATOR (abfd->filename[dirlen - 1]))
+      const char *fname = bfd_get_filename (abfd);
+      for (dirlen = strlen (fname); dirlen > 0; dirlen--)
+       if (IS_DIR_SEPARATOR (fname[dirlen - 1]))
          break;
 
       dir = (char *) bfd_malloc (dirlen + 1);
@@ -1430,7 +1430,7 @@ find_separate_debug_file (bfd *             abfd,
          free (base);
          return NULL;
        }
-      memcpy (dir, abfd->filename, dirlen);
+      memcpy (dir, fname, dirlen);
       dir[dirlen] = '\0';
     }
   else
@@ -1442,7 +1442,7 @@ find_separate_debug_file (bfd *             abfd,
 
   /* Compute the canonical name of the bfd object with all symbolic links
      resolved, for use in the global debugfile directory.  */
-  canon_dir = lrealpath (abfd->filename);
+  canon_dir = lrealpath (bfd_get_filename (abfd));
   for (canon_dirlen = strlen (canon_dir); canon_dirlen > 0; canon_dirlen--)
     if (IS_DIR_SEPARATOR (canon_dir[canon_dirlen - 1]))
       break;
@@ -1909,7 +1909,7 @@ get_build_id_name (bfd *abfd, void *build_id_out_p)
   bfd_size_type s;
   bfd_byte *d;
 
-  if (abfd == NULL || abfd->filename == NULL || build_id_out == NULL)
+  if (abfd == NULL || bfd_get_filename (abfd) == NULL || build_id_out == NULL)
     {
       bfd_set_error (bfd_error_invalid_operation);
       return NULL;
index 5ad95236590ea951a916d8cb14fd5fc7207f2724..4555b36d274cf5d228e8b06e3eefb3416d4a4f63 100644 (file)
@@ -2225,7 +2225,7 @@ NAME (aout, find_nearest_line) (bfd *abfd,
   size_t filelen, funclen;
   char *buf;
 
-  *filename_ptr = abfd->filename;
+  *filename_ptr = bfd_get_filename (abfd);
   *functionname_ptr = 0;
   *line_ptr = 0;
   if (discriminator_ptr)
@@ -4037,13 +4037,14 @@ aout_link_write_symbols (struct aout_final_link_info *flaginfo, bfd *input_bfd)
      discarding such symbols.  */
   if (strip != strip_all
       && (strip != strip_some
-         || bfd_hash_lookup (flaginfo->info->keep_hash, input_bfd->filename,
+         || bfd_hash_lookup (flaginfo->info->keep_hash,
+                             bfd_get_filename (input_bfd),
                              FALSE, FALSE) != NULL)
       && discard != discard_all)
     {
       H_PUT_8 (output_bfd, N_TEXT, outsym->e_type);
       strtab_index = add_to_stringtab (output_bfd, flaginfo->strtab,
-                                      input_bfd->filename, FALSE);
+                                      bfd_get_filename (input_bfd), FALSE);
       if (strtab_index == (bfd_size_type) -1)
        return FALSE;
       PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
index 48387fa53ecbee6488d38afb26571ef18e53952f..9439366f4bf42249b31d718df86955033b9b3b69 100644 (file)
@@ -197,7 +197,7 @@ bfd_plugin_open_input (bfd *ibfd, struct ld_plugin_input_file *file)
   while (iobfd->my_archive
         && !bfd_is_thin_archive (iobfd->my_archive))
     iobfd = iobfd->my_archive;
-  file->name = iobfd->filename;
+  file->name = bfd_get_filename (iobfd);
 
   if (!iobfd->iostream && !bfd_open_file (iobfd))
     return 0;
index 8e2dd06b464c9b199971bf75ee7d71b6a4042d1c..696e8fdd99105cb4b8222da76c4c19959bcc0279 100644 (file)
@@ -759,11 +759,11 @@ rs6000coff_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
     }
 
   str1 = strrchr (path, '/');
-  str2 = strrchr (exec_bfd->filename, '/');
+  str2 = strrchr (bfd_get_filename (exec_bfd), '/');
 
   /* step over character '/' */
   str1 = str1 != NULL ? str1 + 1 : path;
-  str2 = str2 != NULL ? str2 + 1 : exec_bfd->filename;
+  str2 = str2 != NULL ? str2 + 1 : bfd_get_filename (exec_bfd);
 
   if (strcmp (str1, str2) == 0)
     ret = TRUE;
index 5676f0f5008081ad24f94a05a525a5f68bdf6e3b..d36d163bb6b11910325c0581d9f1ad28fbab6045 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -6660,7 +6660,7 @@ som_write_armap (bfd *abfd,
   unsigned int module_count;
 
   /* We'll use this for the archive's date and mode later.  */
-  if (stat (abfd->filename, &statbuf) != 0)
+  if (stat (bfd_get_filename (abfd), &statbuf) != 0)
     {
       bfd_set_error (bfd_error_system_call);
       return FALSE;
index 5ca4f36ae5944ae34cb7c9d7146f03e626efc453..1b3ead81b23f0df8919fd8aa2e31670d11d023e2 100644 (file)
@@ -1015,15 +1015,15 @@ srec_write_record (bfd *abfd,
 static bfd_boolean
 srec_write_header (bfd *abfd)
 {
-  unsigned int len = strlen (abfd->filename);
+  unsigned int len = strlen (bfd_get_filename (abfd));
 
   /* I'll put an arbitrary 40 char limit on header size.  */
   if (len > 40)
     len = 40;
 
   return srec_write_record (abfd, 0, (bfd_vma) 0,
-                           (bfd_byte *) abfd->filename,
-                           (bfd_byte *) abfd->filename + len);
+                           (bfd_byte *) bfd_get_filename (abfd),
+                           (bfd_byte *) bfd_get_filename (abfd) + len);
 }
 
 static bfd_boolean
@@ -1089,9 +1089,9 @@ srec_write_symbols (bfd *abfd)
       bfd_size_type len;
       asymbol **table = bfd_get_outsymbols (abfd);
 
-      len = strlen (abfd->filename);
+      len = strlen (bfd_get_filename (abfd));
       if (bfd_bwrite ("$$ ", (bfd_size_type) 3, abfd) != 3
-         || bfd_bwrite (abfd->filename, len, abfd) != len
+         || bfd_bwrite (bfd_get_filename (abfd), len, abfd) != len
          || bfd_bwrite ("\r\n", (bfd_size_type) 2, abfd) != 2)
        return FALSE;
 
index a6335218fa491671c167c2854ff3ac0c06b968d4..9504cf4976c0e839607be453d879cc62443ca329 100644 (file)
@@ -1491,7 +1491,7 @@ bfd *
 _bfd_vms_lib_get_imagelib_file (bfd *el)
 {
   bfd *archive = el->my_archive;
-  const char *modname = el->filename;
+  const char *modname = bfd_get_filename (el);
   int modlen = strlen (modname);
   char *filename;
   int j;
@@ -1517,7 +1517,7 @@ _bfd_vms_lib_get_imagelib_file (bfd *el)
     {
       /* xgettext:c-format */
       _bfd_error_handler(_("could not open shared image '%s' from '%s'"),
-                        filename, archive->filename);
+                        filename, bfd_get_filename (archive));
       bfd_release (archive, filename);
       return NULL;
     }
@@ -2152,7 +2152,7 @@ _bfd_vms_lib_write_archive_contents (bfd *arch)
       unsigned int nl;
 
       modules[i].abfd = current;
-      modules[i].name = vms_get_module_name (current->filename, FALSE);
+      modules[i].name = vms_get_module_name (bfd_get_filename (current), FALSE);
       modules[i].ref = 1;
 
       /* FIXME: silently truncate long names ?  */
index 2560d2ca427ae5051868fb554b3b64502dd5c575..503b6ab93f1ed2fc760556a9da09008b3a7ea3a8 100644 (file)
@@ -1000,7 +1000,7 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info)
 
   if (abfd->my_archive == NULL || bfd_is_thin_archive (abfd->my_archive))
     {
-      if (!bfd_xcoff_split_import_path (abfd, abfd->filename,
+      if (!bfd_xcoff_split_import_path (abfd, bfd_get_filename (abfd),
                                        &n->path, &n->file))
        return FALSE;
       n->member = "";
@@ -1013,7 +1013,8 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info)
       if (!archive_info->impfile)
        {
          if (!bfd_xcoff_split_import_path (archive_info->archive,
-                                           archive_info->archive->filename,
+                                           bfd_get_filename (archive_info
+                                                             ->archive),
                                            &archive_info->imppath,
                                            &archive_info->impfile))
            return FALSE;