From: Alan Modra Date: Tue, 19 May 2020 03:05:03 +0000 (+0930) Subject: Use bfd_get_filename throughout bfd X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=765cf5f623dbc2de8c8791bce9a29fcc3492436c;p=binutils-gdb.git Use bfd_get_filename throughout bfd * 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3926bd1005b..d9892235721 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,44 @@ +2020-05-19 Alan Modra + + * 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 PR 25713 diff --git a/bfd/aix5ppc-core.c b/bfd/aix5ppc-core.c index cddb647de13..ba8a4e05240 100644 --- a/bfd/aix5ppc-core.c +++ b/bfd/aix5ppc-core.c @@ -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; diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 365202e0ce3..214c4c5a491 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -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 */ diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 9ffb3fe8610..4cf5713c355 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -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); diff --git a/bfd/archive.c b/bfd/archive.c index 3423a336956..ff64727c448 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -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(); diff --git a/bfd/bfd.c b/bfd/bfd.c index 3aed9be2373..84e74a36b83 100644 --- 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); diff --git a/bfd/cache.c b/bfd/cache.c index ed73c161d2c..93abff33fe2 100644 --- a/bfd/cache.c +++ b/bfd/cache.c @@ -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; diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 82267a889df..1b0d4233e76 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -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)); diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index ba2bbbc868a..dde5593636a 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -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; diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c index e6383a782ff..a51a8e8e9f2 100644 --- a/bfd/elf32-bfin.c +++ b/bfd/elf32-bfin.c @@ -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 diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c index d2a18fd564a..51ea8fa27ed 100644 --- a/bfd/elf32-frv.c +++ b/bfd/elf32-frv.c @@ -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 diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 6d5382dc26d..4b76f941adf 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -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; diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index 6b0b813af0b..a5a681a946d 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -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. */ } diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c index 983989081ae..193438c7979 100644 --- a/bfd/elf32-spu.c +++ b/bfd/elf32-spu.c @@ -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; } } diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index ae50b2cd478..0fdbea45cce 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -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; diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c index 159698fa07f..6fa116f610e 100644 --- a/bfd/elf64-ia64-vms.c +++ b/bfd/elf64-ia64-vms.c @@ -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; diff --git a/bfd/elfcore.h b/bfd/elfcore.h index 44707ebb60f..0339a671fc7 100644 --- a/bfd/elfcore.h +++ b/bfd/elfcore.h @@ -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; diff --git a/bfd/elflink.c b/bfd/elflink.c index 6624864bf54..90ada7a1cca 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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); diff --git a/bfd/linker.c b/bfd/linker.c index c523f8b5c64..3820ce14f83 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -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; diff --git a/bfd/mach-o.c b/bfd/mach-o.c index ee58a7adfae..33bd81e121e 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -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; diff --git a/bfd/opncls.c b/bfd/opncls.c index 99097a9e399..5d3437d3822 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -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; diff --git a/bfd/pdp11.c b/bfd/pdp11.c index 5ad95236590..4555b36d274 100644 --- a/bfd/pdp11.c +++ b/bfd/pdp11.c @@ -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); diff --git a/bfd/plugin.c b/bfd/plugin.c index 48387fa53ec..9439366f4bf 100644 --- a/bfd/plugin.c +++ b/bfd/plugin.c @@ -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; diff --git a/bfd/rs6000-core.c b/bfd/rs6000-core.c index 8e2dd06b464..696e8fdd991 100644 --- a/bfd/rs6000-core.c +++ b/bfd/rs6000-core.c @@ -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; diff --git a/bfd/som.c b/bfd/som.c index 5676f0f5008..d36d163bb6b 100644 --- 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; diff --git a/bfd/srec.c b/bfd/srec.c index 5ca4f36ae59..1b3ead81b23 100644 --- a/bfd/srec.c +++ b/bfd/srec.c @@ -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; diff --git a/bfd/vms-lib.c b/bfd/vms-lib.c index a6335218fa4..9504cf4976c 100644 --- a/bfd/vms-lib.c +++ b/bfd/vms-lib.c @@ -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 ? */ diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index 2560d2ca427..503b6ab93f1 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -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;