+# Test building a thin archive.
+
+proc thin_archive { } {
+ global AR
+ global AS
+ global NM
+ global srcdir
+ global subdir
+
+ set testname "ar thin archive"
+
+ if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o] {
+ unresolved $testname
+ return
+ }
+
+ if [is_remote host] {
+ set archive artest.a
+ set objfile [remote_download host tmpdir/bintest.o]
+ remote_file host delete $archive
+ } else {
+ set archive tmpdir/artest.a
+ set objfile tmpdir/bintest.o
+ }
+
+ remote_file build delete tmpdir/artest.a
+
+ set got [binutils_run $AR "rcT $archive ${objfile}"]
+ if ![string match "" $got] {
+ fail $testname
+ return
+ }
+
+ set got [binutils_run $NM "--print-armap $archive"]
+ if { ![string match "*text_symbol in *bintest.o*" $got] \
+ || ![string match "*data_symbol in *bintest.o*" $got] \
+ || ![string match "*common_symbol in *bintest.o*" $got] \
+ || [string match "*static_text_symbol in *bintest.o*" $got] \
+ || [string match "*static_data_symbol in *bintest.o*" $got] \
+ || [string match "*external_symbol in *bintest.o*" $got] } {
+ fail $testname
+ return
+ }
+
+ pass $testname
+}
+
+# Test building a thin archive with a nested archive.
+
+proc thin_archive_with_nested { } {
+ global AR
+ global AS
+ global NM
+ global srcdir
+ global subdir
+
+ set testname "ar thin archive with nested archive"
+
+ if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o] {
+ unresolved $testname
+ return
+ }
+
+ if [is_remote host] {
+ set archive artest.a
+ set archive2 artest2.a
+ set objfile [remote_download host tmpdir/bintest.o]
+ remote_file host delete $archive
+ } else {
+ set archive tmpdir/artest.a
+ set archive2 tmpdir/artest2.a
+ set objfile tmpdir/bintest.o
+ }
+
+ remote_file build delete tmpdir/artest.a
+
+ set got [binutils_run $AR "rc $archive ${objfile}"]
+ if ![string match "" $got] {
+ fail $testname
+ return
+ }
+
+ remote_file build delete tmpdir/artest2.a
+
+ set got [binutils_run $AR "rcT $archive2 ${archive}"]
+ if ![string match "" $got] {
+ fail $testname
+ return
+ }
+
+ set got [binutils_run $NM "--print-armap $archive"]
+ if { ![string match "*text_symbol in *bintest.o*" $got] \
+ || ![string match "*data_symbol in *bintest.o*" $got] \
+ || ![string match "*common_symbol in *bintest.o*" $got] \
+ || [string match "*static_text_symbol in *bintest.o*" $got] \
+ || [string match "*static_data_symbol in *bintest.o*" $got] \
+ || [string match "*external_symbol in *bintest.o*" $got] } {
+ fail $testname
+ return
+ }
+
+ pass $testname
+}
+