[PATCH] bfd: Set error to bfd_error_malformed_archive only if unset
H.J. Lu
hjl.tools@gmail.com
Mon Jul 26 12:59:02 GMT 2021
When reading an archive member, set error to bfd_error_malformed_archive
on open_nested_file failure only if the error is unset.
PR ld/28138
* archive.c (_bfd_get_elt_at_filepos): Don't set error to
bfd_error_malformed_archive if it has been set.
---
bfd/archive.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/bfd/archive.c b/bfd/archive.c
index 5f350b8e5ce..3868fc9f7ed 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -713,8 +713,9 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
/* It's not an element of a nested archive;
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)
+ if (n_bfd == NULL && bfd_get_error () == bfd_error_no_error)
bfd_set_error (bfd_error_malformed_archive);
}
else
--
2.31.1
More information about the Binutils
mailing list