aboutsummaryrefslogtreecommitdiff
path: root/bfd/archive.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-12-24 16:04:03 -0800
committerH.J. Lu <hjl.tools@gmail.com>2022-01-04 09:51:02 -0800
commit6395a1021020671dd205d332b2879e3e733e8024 (patch)
tree157a55dff238a612e95fe3a8d6fe8b4b1ca8724c /bfd/archive.c
parent0b1e7ee5b572abb465b8095d7f92d49eed91e215 (diff)
downloadgdb-6395a1021020671dd205d332b2879e3e733e8024.zip
gdb-6395a1021020671dd205d332b2879e3e733e8024.tar.gz
gdb-6395a1021020671dd205d332b2879e3e733e8024.tar.bz2
ld: Improve thin archive member error message
Improve thin archive member error message with: ld: libbar.a(bar.o): error opening thin archive member: No such file or directory instead of ld: libbar.a: error adding symbols: No such file or directory PR ld/28722 * archive.c (_bfd_get_elt_at_filepos): Add a pointer argument for struct bfd_link_info. Call linker callback when failing to open thin archive member. (_bfd_generic_get_elt_at_index): Pass NULL to _bfd_get_elt_at_filepos. (bfd_generic_openr_next_archived_file): Likewise. * coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Add a pointer argument for struct bfd_link_info and pass it to _bfd_get_elt_at_filepos. (alpha_ecoff_openr_next_archived_file): Pass NULL to _bfd_get_elt_at_filepos. (alpha_ecoff_get_elt_at_index): Likewise. * coff-rs6000.c (_bfd_xcoff_openr_next_archived_file): Likewise. * ecoff.c (ecoff_link_add_archive_symbols): Pass info to backend->get_elt_at_filepos. * elflink.c (elf_link_is_defined_archive_symbol): info to _bfd_get_elt_at_filepos. * libbfd-in.h (_bfd_get_elt_at_filepos): Add a pointer argument for struct bfd_link_info. * libbfd.h: Regenerate. * libecoff.h (ecoff_backend_data): Add a pointer argument for struct bfd_link_info to get_elt_at_filepos. * linker.c (_bfd_generic_link_add_archive_symbols): Pass info to _bfd_get_elt_at_filepos.
Diffstat (limited to 'bfd/archive.c')
-rw-r--r--bfd/archive.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/bfd/archive.c b/bfd/archive.c
index f9b8b14..9ad61ad 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -651,7 +651,8 @@ _bfd_append_relative_path (bfd *arch, char *elt_name)
element, since it handles the bookkeeping so nicely for us. */
bfd *
-_bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
+_bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos,
+ struct bfd_link_info *info)
{
struct areltdata *new_areldata;
bfd *n_bfd;
@@ -694,7 +695,8 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
free (new_areldata);
return NULL;
}
- n_bfd = _bfd_get_elt_at_filepos (ext_arch, new_areldata->origin);
+ n_bfd = _bfd_get_elt_at_filepos (ext_arch,
+ new_areldata->origin, info);
if (n_bfd == NULL)
{
free (new_areldata);
@@ -715,8 +717,26 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
open the external file as a bfd. */
bfd_set_error (bfd_error_no_error);
n_bfd = open_nested_file (filename, archive);
- if (n_bfd == NULL && bfd_get_error () == bfd_error_no_error)
- bfd_set_error (bfd_error_malformed_archive);
+ if (n_bfd == NULL)
+ {
+ switch (bfd_get_error ())
+ {
+ default:
+ break;
+ case bfd_error_no_error:
+ bfd_set_error (bfd_error_malformed_archive);
+ break;
+ case bfd_error_system_call:
+ if (info != NULL)
+ {
+ info->callbacks->einfo
+ (_("%F%P: %pB(%s): error opening thin archive member: %E\n"),
+ archive, filename);
+ break;
+ }
+ break;
+ }
+ }
}
else
{
@@ -772,7 +792,7 @@ _bfd_generic_get_elt_at_index (bfd *abfd, symindex sym_index)
carsym *entry;
entry = bfd_ardata (abfd)->symdefs + sym_index;
- return _bfd_get_elt_at_filepos (abfd, entry->file_offset);
+ return _bfd_get_elt_at_filepos (abfd, entry->file_offset, NULL);
}
bfd *
@@ -841,7 +861,7 @@ bfd_generic_openr_next_archived_file (bfd *archive, bfd *last_file)
}
}
- return _bfd_get_elt_at_filepos (archive, filestart);
+ return _bfd_get_elt_at_filepos (archive, filestart, NULL);
}
bfd *