return abfd->xvec->keep_unused_section_symbols;
}
+static inline bool
+bfd_target_supports_archives (const bfd *abfd)
+{
+ return (abfd->xvec->_bfd_check_format[bfd_archive]
+ != abfd->xvec->_bfd_check_format[bfd_unknown]);
+}
+
bool bfd_set_default_target (const char *name);
const bfd_target *bfd_find_target (const char *target_name, bfd *abfd);
{
_bfd_bool_bfd_false_error,
msdos_mkobject,
- _bfd_generic_mkarchive,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
msdos_write_object_contents,
- _bfd_write_archive_contents,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{
_bfd_bool_bfd_false_error,
ihex_mkobject,
- _bfd_generic_mkarchive,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents. */
_bfd_bool_bfd_false_error,
ihex_write_object_contents,
- _bfd_write_archive_contents,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
ptrace_unix_core_file_p /* a core file */
},
{ /* bfd_set_format */
- _bfd_bool_bfd_false_error, bfd_false,
- _bfd_bool_bfd_false_error, bfd_false
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents */
- _bfd_bool_bfd_false_error, bfd_false,
- _bfd_bool_bfd_false_error, bfd_false
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error,
+ _bfd_bool_bfd_false_error,
},
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
{
_bfd_bool_bfd_false_error,
srec_mkobject,
- _bfd_generic_mkarchive,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents. */
_bfd_bool_bfd_false_error,
srec_write_object_contents,
- _bfd_write_archive_contents,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{
_bfd_bool_bfd_false_error,
srec_mkobject,
- _bfd_generic_mkarchive,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents. */
_bfd_bool_bfd_false_error,
symbolsrec_write_object_contents,
- _bfd_write_archive_contents,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
. return abfd->xvec->keep_unused_section_symbols;
.}
.
+.static inline bool
+.bfd_target_supports_archives (const bfd *abfd)
+.{
+. return (abfd->xvec->_bfd_check_format[bfd_archive]
+. != abfd->xvec->_bfd_check_format[bfd_unknown]);
+.}
+.
*/
/* All known xvecs (even those that don't compile on all systems).
{
_bfd_bool_bfd_false_error,
tekhex_mkobject,
- _bfd_generic_mkarchive,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents. */
_bfd_bool_bfd_false_error,
tekhex_write_object_contents,
- _bfd_write_archive_contents,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{
_bfd_bool_bfd_false_error,
wasm_mkobject,
- _bfd_generic_mkarchive,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents. */
_bfd_bool_bfd_false_error,
wasm_write_object_contents,
- _bfd_write_archive_contents,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
obj = bfd_openr (file, target);
if (obj != NULL)
{
- if (bfd_check_format (obj, bfd_object))
+ if (bfd_check_format (obj, bfd_object)
+ && bfd_target_supports_archives (obj))
target = bfd_get_target (obj);
(void) bfd_close (obj);
}
}
+ /* If we die creating a new archive, don't leave it around. */
+ output_filename = xstrdup (archive_filename);
+
/* Create an empty archive. */
arch = bfd_openw (archive_filename, target);
if (arch == NULL
bfd_fatal (archive_filename);
else if (!silent_create)
non_fatal (_("creating %s"), archive_filename);
-
- /* If we die creating a new archive, don't leave it around. */
- output_filename = xstrdup (archive_filename);
}
arch = bfd_openr (archive_filename, target);
if [is_remote host] {
set archive artest.a
set archive2 artest2.a
- set archive3 artest3.a
set objfile [remote_download host tmpdir/bintest.${obj}]
remote_file host delete $archive
} else {
set archive tmpdir/artest.a
set archive2 tmpdir/artest2.a
- set archive3 tmpdir/artest3.a
set objfile tmpdir/bintest.${obj}
}
remote_file build delete tmpdir/artest2.a
- set got [binutils_run $AR "rcT $archive2 ${archive}"]
- if ![string match "" $got] {
- fail $testname
- return
- }
-
- remote_file build delete tmpdir/artest3.a
-
- set got [binutils_run $AR "rc --thin $archive3 ${archive}"]
+ set got [binutils_run $AR "rc --thin $archive2 ${archive}"]
if ![string match "" $got] {
fail $testname
return
fail "$testname ($bfdtest)"
return
}
-
- set exec_output [binutils_run "$base_dir/$bfdtest" "$archive3"]
- if ![string match "" $exec_output] {
- verbose -log $exec_output
- fail "$testname ($bfdtest)"
- return
- }
}
set got [binutils_run $NM "--print-armap $archive"]
pass $testname
}
+# Test creation of an archive containing object files not of the same
+# format as the target object files.
+
+proc foreign_object { } {
+ global AR
+ global NM
+ global srcdir
+ global subdir
+
+ set testname "ar foreign object"
+
+ set object1 $srcdir/$subdir/tek1.obj
+ set object2 $srcdir/$subdir/tek2.obj
+ if [is_remote host] {
+ set archive artest.a
+ set object1 [remote_download host $object1]
+ set object2 [remote_download host $object2]
+ remote_file host delete $archive
+ } else {
+ set archive tmpdir/artest.a
+ }
+
+ remote_file build delete tmpdir/artest.a
+
+ set got [binutils_run $AR "rc $archive $object1 $object2"]
+ if ![string match {} $got] {
+ fail $testname
+ return
+ }
+
+ set got [binutils_run $NM $archive]
+ if ![string match {
+tek1.obj:
+*: no symbols
+
+tek2.obj:
+00000001 D _binary_x_end
+00000001 A _binary_x_size
+00000000 D _binary_x_start
+} $got] {
+ fail $testname
+ return
+ }
+
+ pass $testname
+}
+
+
# Run the tests.
# Only run the bfdtest checks if the programs exist. Since these
if { [is_elf_format] && [supports_gnu_unique] } {
unique_symbol
}
+
+foreign_object
--- /dev/null
+%47615103000000000000000000000000000000000000000000000000000000000000000
+%0781010
--- /dev/null
+%47615103000000000000000000000000000000000000000000000000000000000000000
+%103E95.data11011
+%1E3FB5.data4F_binary_x_start10
+%1C3735.data4D_binary_x_end11
+%1D3135*ABS*2E_binary_x_size11
+%0781010