1 *** binutils/objcopy.c 5 Sep 2006 08:22:27 -0000 1.98
2 --- binutils/objcopy.c 8 Sep 2006 15:01:35 -0000
3 *************** copy_object (bfd *ibfd, bfd *obfd)
7 /* Read each archive element in turn from IBFD, copy the
8 ! contents to temp file, and keep the temp file handle. */
11 ! copy_archive (bfd *ibfd, bfd *obfd, const char *output_target)
18 /* Read each archive element in turn from IBFD, copy the
19 ! contents to temp file, and keep the temp file handle.
20 ! If 'force_output_target' is TRUE then make sure that
21 ! all elements in the new archive are of the type
25 ! copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
26 ! bfd_boolean force_output_target)
30 *************** copy_archive (bfd *ibfd, bfd *obfd, cons
32 bfd_get_filename (this_element), (char *) 0);
35 - output_bfd = bfd_openw (output_name, output_target);
38 stat_status = bfd_stat_arch_elt (this_element, &buf);
40 *************** copy_archive (bfd *ibfd, bfd *obfd, cons
45 - if (output_bfd == NULL)
46 - RETURN_NONFATAL (output_name);
48 if (bfd_check_format (this_element, bfd_object))
50 delete = ! copy_object (this_element, output_bfd);
57 if (bfd_check_format (this_element, bfd_object))
59 + /* PR binutils/3110: Cope with archives
60 + containing multiple target types. */
61 + if (force_output_target)
62 + output_bfd = bfd_openw (output_name, output_target);
64 + output_bfd = bfd_openw (output_name, bfd_get_target (this_element));
66 + if (output_bfd == NULL)
67 + RETURN_NONFATAL (output_name);
69 delete = ! copy_object (this_element, output_bfd);
72 *************** copy_archive (bfd *ibfd, bfd *obfd, cons
75 non_fatal (_("Unable to recognise the format of the input file `%s'"),
76 bfd_get_archive_filename (this_element));
78 + output_bfd = bfd_openw (output_name, output_target);
80 delete = !copy_unknown_object (this_element, output_bfd);
81 if (!bfd_close_all_done (output_bfd))
82 *************** copy_file (const char *input_filename, c
85 if (bfd_check_format (ibfd, bfd_archive))
89 /* bfd_get_target does not return the correct value until
90 bfd_check_format succeeds. */
91 if (output_target == NULL)
92 ! output_target = bfd_get_target (ibfd);
94 obfd = bfd_openw (output_filename, output_target);
96 RETURN_NONFATAL (output_filename);
98 ! copy_archive (ibfd, obfd, output_target);
100 else if (bfd_check_format_matches (ibfd, bfd_object, &obj_matching))
104 if (bfd_check_format (ibfd, bfd_archive))
106 + bfd_boolean force_output_target;
109 /* bfd_get_target does not return the correct value until
110 bfd_check_format succeeds. */
111 if (output_target == NULL)
113 ! output_target = bfd_get_target (ibfd);
114 ! force_output_target = FALSE;
117 ! force_output_target = TRUE;
119 obfd = bfd_openw (output_filename, output_target);
121 RETURN_NONFATAL (output_filename);
123 ! copy_archive (ibfd, obfd, output_target, force_output_target);
125 else if (bfd_check_format_matches (ibfd, bfd_object, &obj_matching))