From 95b91a043aeaeb546d2fea556d84a2de1e917770 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 1 Feb 2021 02:04:41 +1030 Subject: pr27270 and pr27284, ar segfaults and wrong file mode PR 27270 PR 27284 PR 26945 * ar.c: Don't include libbfd.h. (write_archive): Replace xmalloc+strcpy with xstrdup. Use bfd_stat rather than fstat on iostream. Move stat and fd tests outside of _WIN32 ifdef. Delete skip_stat variable. * arsup.c (temp_name, real_ofd): New static variables. (ar_open): Use make_tempname and bfd_fdopenw. (ar_save): Adjust to suit ar_open changes. Move stat output of _WIN32 ifdef. * objcopy.c: Don't include libbfd.h. (copy_file): Use bfd_stat. --- binutils/objcopy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'binutils/objcopy.c') diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 39a1ccb..0e1047e 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -20,7 +20,6 @@ #include "sysdep.h" #include "bfd.h" -#include "libbfd.h" #include "progress.h" #include "getopt.h" #include "libiberty.h" @@ -3768,7 +3767,7 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, /* To allow us to do "strip *" without dying on the first non-object file, failures are nonfatal. */ ibfd = bfd_openr (input_filename, input_target); - if (ibfd == NULL || fstat (fileno ((FILE *) ibfd->iostream), in_stat) != 0) + if (ibfd == NULL || bfd_stat (ibfd, in_stat) != 0) { bfd_nonfatal_message (input_filename, NULL, NULL, NULL); status = 1; -- cgit v1.1