]>
Commit | Line | Data |
---|---|---|
76d05fa0 PS |
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) | |
4 | *** 1730,1739 **** | |
5 | #endif | |
6 | ||
7 | /* Read each archive element in turn from IBFD, copy the | |
8 | ! contents to temp file, and keep the temp file handle. */ | |
9 | ||
10 | static void | |
11 | ! copy_archive (bfd *ibfd, bfd *obfd, const char *output_target) | |
12 | { | |
13 | struct name_list | |
14 | { | |
15 | --- 1730,1743 ---- | |
16 | #endif | |
17 | ||
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 | |
22 | ! 'output_target'. */ | |
23 | ||
24 | static void | |
25 | ! copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, | |
26 | ! bfd_boolean force_output_target) | |
27 | { | |
28 | struct name_list | |
29 | { | |
30 | *************** copy_archive (bfd *ibfd, bfd *obfd, cons | |
31 | *** 1789,1795 **** | |
32 | bfd_get_filename (this_element), (char *) 0); | |
33 | } | |
34 | ||
35 | - output_bfd = bfd_openw (output_name, output_target); | |
36 | if (preserve_dates) | |
37 | { | |
38 | stat_status = bfd_stat_arch_elt (this_element, &buf); | |
39 | --- 1793,1798 ---- | |
40 | *************** copy_archive (bfd *ibfd, bfd *obfd, cons | |
41 | *** 1805,1815 **** | |
42 | l->obfd = NULL; | |
43 | list = l; | |
44 | ||
45 | - if (output_bfd == NULL) | |
46 | - RETURN_NONFATAL (output_name); | |
47 | - | |
48 | if (bfd_check_format (this_element, bfd_object)) | |
49 | { | |
50 | delete = ! copy_object (this_element, output_bfd); | |
51 | ||
52 | if (! delete | |
53 | --- 1808,1825 ---- | |
54 | l->obfd = NULL; | |
55 | list = l; | |
56 | ||
57 | if (bfd_check_format (this_element, bfd_object)) | |
58 | { | |
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); | |
63 | + else | |
64 | + output_bfd = bfd_openw (output_name, bfd_get_target (this_element)); | |
65 | + | |
66 | + if (output_bfd == NULL) | |
67 | + RETURN_NONFATAL (output_name); | |
68 | + | |
69 | delete = ! copy_object (this_element, output_bfd); | |
70 | ||
71 | if (! delete | |
72 | *************** copy_archive (bfd *ibfd, bfd *obfd, cons | |
73 | *** 1830,1835 **** | |
74 | --- 1840,1846 ---- | |
75 | non_fatal (_("Unable to recognise the format of the input file `%s'"), | |
76 | bfd_get_archive_filename (this_element)); | |
77 | ||
78 | + output_bfd = bfd_openw (output_name, output_target); | |
79 | copy_unknown_element: | |
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 | |
83 | *** 1911,1928 **** | |
84 | ||
85 | if (bfd_check_format (ibfd, bfd_archive)) | |
86 | { | |
87 | bfd *obfd; | |
88 | ||
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); | |
93 | ||
94 | obfd = bfd_openw (output_filename, output_target); | |
95 | if (obfd == NULL) | |
96 | RETURN_NONFATAL (output_filename); | |
97 | ||
98 | ! copy_archive (ibfd, obfd, output_target); | |
99 | } | |
100 | else if (bfd_check_format_matches (ibfd, bfd_object, &obj_matching)) | |
101 | { | |
102 | --- 1922,1945 ---- | |
103 | ||
104 | if (bfd_check_format (ibfd, bfd_archive)) | |
105 | { | |
106 | + bfd_boolean force_output_target; | |
107 | bfd *obfd; | |
108 | ||
109 | /* bfd_get_target does not return the correct value until | |
110 | bfd_check_format succeeds. */ | |
111 | if (output_target == NULL) | |
112 | ! { | |
113 | ! output_target = bfd_get_target (ibfd); | |
114 | ! force_output_target = FALSE; | |
115 | ! } | |
116 | ! else | |
117 | ! force_output_target = TRUE; | |
118 | ||
119 | obfd = bfd_openw (output_filename, output_target); | |
120 | if (obfd == NULL) | |
121 | RETURN_NONFATAL (output_filename); | |
122 | ||
123 | ! copy_archive (ibfd, obfd, output_target, force_output_target); | |
124 | } | |
125 | else if (bfd_check_format_matches (ibfd, bfd_object, &obj_matching)) | |
126 | { |