2021-01-01 06:58:58 +08:00
|
|
|
# Copyright (C) 1995-2021 Free Software Foundation, Inc.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-06 00:54:46 +08:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1999-05-03 15:29:11 +08:00
|
|
|
# (at your option) any later version.
|
2018-05-31 00:06:26 +08:00
|
|
|
#
|
1999-05-03 15:29:11 +08:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2018-05-31 00:06:26 +08:00
|
|
|
#
|
1999-05-03 15:29:11 +08:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2005-05-08 22:17:41 +08:00
|
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
|
|
|
# bug-dejagnu@prep.ai.mit.edu
|
|
|
|
|
|
|
|
# Written by Ian Lance Taylor <ian@cygnus.com>
|
|
|
|
|
|
|
|
if ![is_remote host] {
|
|
|
|
if {[which $AR] == 0} then {
|
|
|
|
perror "$AR does not exist"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
set obj o
|
|
|
|
if { [istarget "*-*-vms"] } then {
|
|
|
|
set obj obj
|
2016-06-22 21:42:26 +08:00
|
|
|
}
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
# send_user "Version [binutil_version $AR]"
|
|
|
|
|
|
|
|
# Test long file name support
|
|
|
|
|
2012-11-07 07:45:43 +08:00
|
|
|
proc long_filenames { bfdtests } {
|
1999-05-03 15:29:11 +08:00
|
|
|
global AR
|
|
|
|
global host_triplet
|
2012-11-07 07:45:43 +08:00
|
|
|
global base_dir
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
set testname "ar long file names"
|
|
|
|
|
|
|
|
set n1 "abcdefghijklmnopqrstuvwxyz1"
|
|
|
|
set n2 "abcdefghijklmnopqrstuvwxyz2"
|
|
|
|
set file1 tmpdir/$n1
|
|
|
|
set file2 tmpdir/$n2
|
|
|
|
|
|
|
|
remote_file build delete $file1
|
2007-08-28 21:21:58 +08:00
|
|
|
remote_file host delete $n1
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
# Some file systems truncate file names at 14 characters, which
|
|
|
|
# makes it impossible to run this test. Check for that now.
|
|
|
|
set status [catch "set f [open tmpdir/$n1 w]" errs]
|
|
|
|
if { $status != 0 } {
|
|
|
|
verbose -log "open tmpdir/$n1 returned $errs"
|
|
|
|
unsupported $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
puts $f "first"
|
|
|
|
close $f
|
|
|
|
|
|
|
|
remote_file build delete $file2
|
2007-08-28 21:21:58 +08:00
|
|
|
remote_file host delete $n2
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
set status [catch "set f [open tmpdir/$n2 w]" errs]
|
|
|
|
if { $status != 0 } {
|
|
|
|
verbose -log "open tmpdir/$n2 returned $errs"
|
|
|
|
unsupported $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
puts $f "second"
|
|
|
|
close $f
|
|
|
|
|
|
|
|
if [is_remote host] {
|
2004-05-12 11:28:46 +08:00
|
|
|
set file1 [remote_download host $file1]
|
|
|
|
set file2 [remote_download host $file2]
|
1999-05-03 15:29:11 +08:00
|
|
|
set dest artest.a
|
|
|
|
} else {
|
|
|
|
set dest tmpdir/artest.a
|
|
|
|
}
|
|
|
|
|
2004-05-12 11:28:46 +08:00
|
|
|
remote_file host delete $dest
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
set got [binutils_run $AR "rc $dest $file1 $file2"]
|
|
|
|
if [is_remote host] {
|
|
|
|
remote_upload host $file1 tmpdir/$n1
|
|
|
|
}
|
|
|
|
|
|
|
|
set f [open tmpdir/$n1 r]
|
|
|
|
gets $f string
|
|
|
|
close $f
|
|
|
|
if ![string match "first" $string] {
|
|
|
|
verbose -log "reading tmpdir/$n1 returned $string"
|
|
|
|
unsupported $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2004-05-12 11:28:46 +08:00
|
|
|
remote_file host delete $dest
|
1999-05-03 15:29:11 +08:00
|
|
|
set got [binutils_run $AR "rc $dest $file1 $file2"]
|
|
|
|
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete tmpdir/$n1
|
|
|
|
remote_file build delete tmpdir/$n2
|
|
|
|
|
|
|
|
set got [binutils_run $AR "t $dest"]
|
2004-05-12 11:28:46 +08:00
|
|
|
regsub "\[\r\n \t\]*$" "$got" "" got
|
1999-05-03 15:29:11 +08:00
|
|
|
if ![string match "$n1*$n2" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
2018-05-31 00:06:26 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if [is_remote host] {
|
2004-05-12 11:28:46 +08:00
|
|
|
remote_file host delete $file1
|
|
|
|
remote_file host delete $file2
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
set exec_output [binutils_run $AR "x $dest"]
|
|
|
|
set exec_output [prune_warnings $exec_output]
|
|
|
|
if ![string match "" $exec_output] {
|
|
|
|
verbose -log $exec_output
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2012-11-07 07:45:43 +08:00
|
|
|
foreach bfdtest $bfdtests {
|
|
|
|
set exec_output [binutils_run "$base_dir/$bfdtest" "$dest"]
|
|
|
|
if ![string match "" $exec_output] {
|
|
|
|
verbose -log $exec_output
|
|
|
|
fail "$testname ($bfdtest)"
|
|
|
|
return
|
|
|
|
}
|
2012-08-17 04:31:34 +08:00
|
|
|
}
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if [is_remote host] {
|
2004-05-12 11:28:46 +08:00
|
|
|
remote_upload host $n1 tmpdir/$n1
|
|
|
|
remote_upload host $n2 tmpdir/$n2
|
1999-05-03 15:29:11 +08:00
|
|
|
set file1 tmpdir/$n1
|
|
|
|
set file2 tmpdir/$n2
|
|
|
|
} else {
|
|
|
|
set file1 $n1
|
|
|
|
set file2 $n2
|
|
|
|
}
|
|
|
|
|
|
|
|
if ![file exists $file1] {
|
|
|
|
verbose -log "$file1 does not exist"
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if ![file exists $file2] {
|
|
|
|
verbose -log "$file2 does not exist"
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set f [open $file1 r]
|
|
|
|
if { [gets $f line] == -1 || $line != "first" } {
|
|
|
|
verbose -log "$file1 contents:"
|
|
|
|
verbose -log "$line"
|
|
|
|
close $f
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
close $f
|
|
|
|
|
|
|
|
set f [open $file2 r]
|
|
|
|
if { [gets $f line] == -1 || $line != "second" } {
|
|
|
|
verbose -log "$file2 contents:"
|
|
|
|
verbose -log "$line"
|
|
|
|
close $f
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
close $f
|
|
|
|
|
2002-04-11 21:42:03 +08:00
|
|
|
file delete $file1 $file2
|
1999-05-03 15:29:11 +08:00
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test building the symbol table.
|
|
|
|
|
|
|
|
proc symbol_table { } {
|
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global NM
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2020-06-02 13:30:14 +08:00
|
|
|
global obj
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
set testname "ar symbol table"
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.${obj}] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
1999-05-03 15:29:11 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if [is_remote host] {
|
|
|
|
set archive artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile [remote_download host tmpdir/bintest.${obj}]
|
1999-05-03 15:29:11 +08:00
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
|
|
|
set archive tmpdir/artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile tmpdir/bintest.${obj}
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete tmpdir/artest.a
|
|
|
|
|
|
|
|
set got [binutils_run $AR "rc $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set got [binutils_run $NM "--print-armap $archive"]
|
2020-06-02 13:30:14 +08:00
|
|
|
if { ![string match "*text_symbol in bintest.${obj}*" $got] \
|
|
|
|
|| ![string match "*data_symbol in bintest.${obj}*" $got] \
|
|
|
|
|| ![string match "*common_symbol in bintest.${obj}*" $got] \
|
|
|
|
|| [string match "*static_text_symbol in bintest.${obj}*" $got] \
|
|
|
|
|| [string match "*static_data_symbol in bintest.${obj}*" $got] \
|
|
|
|
|| [string match "*external_symbol in bintest.${obj}*" $got] } {
|
1999-05-03 15:29:11 +08:00
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
2008-03-28 14:49:44 +08:00
|
|
|
# Test building a thin archive.
|
|
|
|
|
2012-11-07 07:45:43 +08:00
|
|
|
proc thin_archive { bfdtests } {
|
2008-03-28 14:49:44 +08:00
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global NM
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2012-11-07 07:45:43 +08:00
|
|
|
global base_dir
|
2020-06-02 13:30:14 +08:00
|
|
|
global obj
|
2008-03-28 14:49:44 +08:00
|
|
|
|
|
|
|
set testname "ar thin archive"
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.${obj}] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
2008-03-28 14:49:44 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if [is_remote host] {
|
|
|
|
set archive artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile [remote_download host tmpdir/bintest.${obj}]
|
2008-03-28 14:49:44 +08:00
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
|
|
|
set archive tmpdir/artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile tmpdir/bintest.${obj}
|
2008-03-28 14:49:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete tmpdir/artest.a
|
|
|
|
|
|
|
|
set got [binutils_run $AR "rcT $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2012-11-07 07:45:43 +08:00
|
|
|
foreach bfdtest $bfdtests {
|
|
|
|
set exec_output [binutils_run "$base_dir/$bfdtest" "$archive"]
|
|
|
|
if ![string match "" $exec_output] {
|
|
|
|
verbose -log $exec_output
|
|
|
|
fail "$testname ($bfdtest)"
|
|
|
|
return
|
|
|
|
}
|
2012-08-17 04:31:34 +08:00
|
|
|
}
|
|
|
|
|
2008-03-28 14:49:44 +08:00
|
|
|
set got [binutils_run $NM "--print-armap $archive"]
|
2020-06-02 13:30:14 +08:00
|
|
|
if { ![string match "*text_symbol in *bintest.${obj}*" $got] \
|
|
|
|
|| ![string match "*data_symbol in *bintest.${obj}*" $got] \
|
|
|
|
|| ![string match "*common_symbol in *bintest.${obj}*" $got] \
|
|
|
|
|| [string match "*static_text_symbol in *bintest.${obj}*" $got] \
|
|
|
|
|| [string match "*static_data_symbol in *bintest.${obj}*" $got] \
|
|
|
|
|| [string match "*external_symbol in *bintest.${obj}*" $got] } {
|
2008-03-28 14:49:44 +08:00
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test building a thin archive with a nested archive.
|
|
|
|
|
2012-11-07 07:45:43 +08:00
|
|
|
proc thin_archive_with_nested { bfdtests } {
|
2008-03-28 14:49:44 +08:00
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global NM
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2012-11-07 07:45:43 +08:00
|
|
|
global base_dir
|
2020-06-02 13:30:14 +08:00
|
|
|
global obj
|
2008-03-28 14:49:44 +08:00
|
|
|
|
|
|
|
set testname "ar thin archive with nested archive"
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.${obj}] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
2008-03-28 14:49:44 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if [is_remote host] {
|
|
|
|
set archive artest.a
|
|
|
|
set archive2 artest2.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile [remote_download host tmpdir/bintest.${obj}]
|
2008-03-28 14:49:44 +08:00
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
|
|
|
set archive tmpdir/artest.a
|
|
|
|
set archive2 tmpdir/artest2.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile tmpdir/bintest.${obj}
|
2008-03-28 14:49:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-11-07 07:45:43 +08:00
|
|
|
foreach bfdtest $bfdtests {
|
|
|
|
set exec_output [binutils_run "$base_dir/$bfdtest" "$archive"]
|
|
|
|
if ![string match "" $exec_output] {
|
|
|
|
verbose -log $exec_output
|
|
|
|
fail "$testname ($bfdtest)"
|
|
|
|
return
|
|
|
|
}
|
2012-08-17 04:31:34 +08:00
|
|
|
|
2012-11-07 07:45:43 +08:00
|
|
|
set exec_output [binutils_run "$base_dir/$bfdtest" "$archive2"]
|
|
|
|
if ![string match "" $exec_output] {
|
|
|
|
verbose -log $exec_output
|
|
|
|
fail "$testname ($bfdtest)"
|
|
|
|
return
|
|
|
|
}
|
2012-08-18 08:18:31 +08:00
|
|
|
}
|
|
|
|
|
2008-03-28 14:49:44 +08:00
|
|
|
set got [binutils_run $NM "--print-armap $archive"]
|
2020-06-02 13:30:14 +08:00
|
|
|
if { ![string match "*text_symbol in *bintest.${obj}*" $got] \
|
|
|
|
|| ![string match "*data_symbol in *bintest.${obj}*" $got] \
|
|
|
|
|| ![string match "*common_symbol in *bintest.${obj}*" $got] \
|
|
|
|
|| [string match "*static_text_symbol in *bintest.${obj}*" $got] \
|
|
|
|
|| [string match "*static_data_symbol in *bintest.${obj}*" $got] \
|
|
|
|
|| [string match "*external_symbol in *bintest.${obj}*" $got] } {
|
2008-03-28 14:49:44 +08:00
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
2004-02-27 19:04:36 +08:00
|
|
|
# Test POSIX-compatible argument parsing.
|
|
|
|
|
|
|
|
proc argument_parsing { } {
|
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2020-06-02 13:30:14 +08:00
|
|
|
global obj
|
2004-02-27 19:04:36 +08:00
|
|
|
|
|
|
|
set testname "ar argument parsing"
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.${obj}] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
2004-02-27 19:04:36 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if [is_remote host] {
|
|
|
|
set archive artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile [remote_download host tmpdir/bintest.${obj}]
|
2004-02-27 19:04:36 +08:00
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
|
|
|
set archive tmpdir/artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile tmpdir/bintest.${obj}
|
2004-02-27 19:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete tmpdir/artest.a
|
|
|
|
|
|
|
|
set got [binutils_run $AR "-r -c $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
2009-03-11 12:36:40 +08:00
|
|
|
# Test building a deterministic archive.
|
|
|
|
|
|
|
|
proc deterministic_archive { } {
|
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global NM
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2020-06-02 13:30:14 +08:00
|
|
|
global obj
|
2009-03-11 12:36:40 +08:00
|
|
|
|
|
|
|
set testname "ar deterministic archive"
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.${obj}] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
2009-03-11 12:36:40 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if [is_remote host] {
|
|
|
|
set archive artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile [remote_download host tmpdir/bintest.${obj}]
|
2009-03-11 12:36:40 +08:00
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
|
|
|
set archive tmpdir/artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile tmpdir/bintest.${obj}
|
2009-03-11 12:36:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete tmpdir/artest.a
|
|
|
|
|
|
|
|
set got [binutils_run $AR "rcD $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set got [binutils_run $AR "tv $archive"]
|
|
|
|
# This only checks the file mode and uid/gid. We can't easily match
|
|
|
|
# date because it's printed with the user's timezone.
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![string match "rw-r--r-- 0/0 *bintest.${obj}*" $got] {
|
2009-03-11 12:36:40 +08:00
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-05-31 00:06:26 +08:00
|
|
|
set got [binutils_run $AR "tvO $archive"]
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![string match "rw-r--r-- 0/0 *bintest.${obj} 0x*" $got] {
|
2018-05-31 00:06:26 +08:00
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2009-03-11 12:36:40 +08:00
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
2010-03-26 09:42:36 +08:00
|
|
|
proc unique_symbol { } {
|
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global NM
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2020-06-02 13:30:14 +08:00
|
|
|
global obj
|
2010-03-26 09:42:36 +08:00
|
|
|
|
|
|
|
set testname "ar unique symbol in archive"
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.${obj}] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
2017-12-15 14:38:56 +08:00
|
|
|
return
|
2010-03-26 09:42:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if [is_remote host] {
|
|
|
|
set archive artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile [remote_download host tmpdir/unique.${obj}]
|
2010-03-26 09:42:36 +08:00
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
|
|
|
set archive tmpdir/artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile tmpdir/unique.${obj}
|
2010-03-26 09:42:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete tmpdir/artest.a
|
|
|
|
|
|
|
|
set got [binutils_run $AR "-s -r -c $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set got [binutils_run $NM "--print-armap $archive"]
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![string match "*foo in *unique.${obj}*" $got] {
|
2010-03-26 09:42:36 +08:00
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
2011-05-02 20:47:47 +08:00
|
|
|
# Test deleting an element.
|
|
|
|
|
|
|
|
proc delete_an_element { } {
|
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2020-06-02 13:30:14 +08:00
|
|
|
global obj
|
2011-05-02 20:47:47 +08:00
|
|
|
|
|
|
|
set testname "ar deleting an element"
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.${obj}] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
2011-05-02 20:47:47 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if [is_remote host] {
|
|
|
|
set archive artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile [remote_download host tmpdir/bintest.${obj}]
|
2011-05-02 20:47:47 +08:00
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
|
|
|
set archive tmpdir/artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile tmpdir/bintest.${obj}
|
2011-05-02 20:47:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete tmpdir/artest.a
|
|
|
|
|
|
|
|
set got [binutils_run $AR "-r -c $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set got [binutils_run $AR "-d $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test moving an element.
|
|
|
|
|
|
|
|
proc move_an_element { } {
|
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2020-06-02 13:30:14 +08:00
|
|
|
global obj
|
2011-05-02 20:47:47 +08:00
|
|
|
|
|
|
|
set testname "ar moving an element"
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.${obj}] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
2011-05-02 20:47:47 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if [is_remote host] {
|
|
|
|
set archive artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile [remote_download host tmpdir/bintest.${obj}]
|
2011-05-02 20:47:47 +08:00
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
|
|
|
set archive tmpdir/artest.a
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile tmpdir/bintest.${obj}
|
2011-05-02 20:47:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete tmpdir/artest.a
|
|
|
|
|
|
|
|
set got [binutils_run $AR "-r -c $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set got [binutils_run $AR "-m $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
2016-03-08 01:29:25 +08:00
|
|
|
# PR 19775: Test creating and listing archives with an empty element.
|
|
|
|
|
|
|
|
proc empty_archive { } {
|
|
|
|
global AR
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
|
|
|
|
|
|
|
set testname "archive with empty element"
|
|
|
|
|
|
|
|
# FIXME: There ought to be a way to dynamically create an empty file.
|
|
|
|
set empty $srcdir/$subdir/empty
|
2018-05-31 00:06:26 +08:00
|
|
|
|
2016-03-08 01:29:25 +08:00
|
|
|
if [is_remote host] {
|
|
|
|
set archive artest.a
|
|
|
|
set objfile [remote_download host $empty]
|
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
|
|
|
set archive tmpdir/artest.a
|
|
|
|
set objfile $empty
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete tmpdir/artest.a
|
|
|
|
|
|
|
|
set got [binutils_run $AR "-r -c $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
# This commmand used to fail with: "Malformed archive".
|
|
|
|
set got [binutils_run $AR "-t $archive"]
|
|
|
|
if ![string match "empty
" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
2019-10-30 18:50:23 +08:00
|
|
|
# Test extracting an element.
|
|
|
|
|
|
|
|
proc extract_an_element { } {
|
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2020-06-02 13:30:14 +08:00
|
|
|
global obj
|
2019-10-30 18:50:23 +08:00
|
|
|
|
|
|
|
set testname "ar extracting an element"
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.${obj}] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
2019-10-30 18:50:23 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set archive artest.a
|
|
|
|
|
|
|
|
if [is_remote host] {
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile [remote_download host tmpdir/bintest.${obj}]
|
2019-10-30 18:50:23 +08:00
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
2020-06-02 13:30:14 +08:00
|
|
|
set objfile tmpdir/bintest.${obj}
|
2019-10-30 18:50:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete $archive
|
|
|
|
|
|
|
|
set got [binutils_run $AR "-r -c $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set got [binutils_run $AR "--output=tmpdir -x $archive ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete $archive
|
|
|
|
remote_file build delete tmpdir/$archive
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
2020-05-23 06:35:14 +08:00
|
|
|
proc many_files { } {
|
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
2020-06-02 13:30:14 +08:00
|
|
|
global obj
|
2020-05-23 06:35:14 +08:00
|
|
|
|
|
|
|
set testname "ar many files"
|
|
|
|
|
|
|
|
set ofiles {}
|
|
|
|
set max_file 150
|
|
|
|
for { set i 0 } { $i < $max_file } { incr i } {
|
|
|
|
set sfile "tmpdir/d-$i.s"
|
|
|
|
if [catch { set ofd [open $sfile w] } x] {
|
|
|
|
perror "$x"
|
|
|
|
unresolved $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
puts $ofd " .globl data_sym$i"
|
|
|
|
puts $ofd " .data"
|
|
|
|
puts $ofd "data_sym$i:"
|
|
|
|
puts $ofd " .long $i"
|
|
|
|
close $ofd
|
|
|
|
|
2020-06-02 13:30:14 +08:00
|
|
|
set ofile "tmpdir/d-$i.${obj}"
|
2020-05-23 06:35:14 +08:00
|
|
|
if ![binutils_assemble $sfile $ofile] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
2020-05-23 06:35:14 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set objfile $ofile
|
|
|
|
if [is_remote host] {
|
|
|
|
remote_file host delete $sfile
|
|
|
|
set objfile [remote_download host $ofile]
|
|
|
|
remote_file build delete $ofile
|
|
|
|
}
|
|
|
|
remote_file build delete $sfile
|
|
|
|
lappend ofiles $objfile
|
|
|
|
}
|
|
|
|
|
|
|
|
set archive tmpdir/many.a
|
|
|
|
remote_file host delete $archive
|
|
|
|
|
|
|
|
set got [binutils_run $AR "cr $archive $ofiles"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_file host delete $archive
|
|
|
|
eval remote_file host delete $ofiles
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
2020-11-03 23:12:47 +08:00
|
|
|
proc test_add_dependencies { } {
|
|
|
|
global AR
|
|
|
|
global AS
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
|
|
|
global obj
|
|
|
|
|
|
|
|
set testname "ar adding library dependencies"
|
|
|
|
|
|
|
|
if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.${obj}] {
|
2021-02-12 14:35:12 +08:00
|
|
|
unsupported $testname
|
2020-11-03 23:12:47 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if [is_remote host] {
|
|
|
|
set archive artest.a
|
|
|
|
set objfile [remote_download host tmpdir/bintest.${obj}]
|
|
|
|
remote_file host delete $archive
|
|
|
|
} else {
|
|
|
|
set archive tmpdir/artest.a
|
|
|
|
set objfile tmpdir/bintest.${obj}
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_file build delete tmpdir/artest.a
|
|
|
|
|
|
|
|
set got [binutils_run $AR "-r -c $archive --record-libdeps /foo/bar ${objfile}"]
|
|
|
|
if ![string match "" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set got [binutils_run $AR "-t $archive"]
|
|
|
|
if ![string match "*bintest.${obj}
__.LIBDEP*" $got] {
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
# Run the tests.
|
|
|
|
|
2014-06-03 15:37:29 +08:00
|
|
|
# Only run the bfdtest checks if the programs exist. Since these
|
|
|
|
# programs are built but not installed, running the testsuite on an
|
|
|
|
# installed toolchain will produce ERRORs about missing bfdtest1 and
|
|
|
|
# bfdtest2 executables.
|
2020-06-02 13:30:14 +08:00
|
|
|
if { [file exists $base_dir/bfdtest1] && [file exists $base_dir/bfdtest2] } {
|
2014-06-03 15:37:29 +08:00
|
|
|
set bfdtests [list bfdtest1 bfdtest2]
|
|
|
|
|
|
|
|
long_filenames $bfdtests
|
2020-06-02 13:30:14 +08:00
|
|
|
|
|
|
|
# xcoff, ecoff, and vms archive support doesn't handle thin archives
|
2020-07-07 10:00:12 +08:00
|
|
|
if { ![is_xcoff_format]
|
2020-06-02 13:30:14 +08:00
|
|
|
&& ![istarget "*-*-*ecoff"]
|
|
|
|
&& ![istarget "*-*-vms"] } {
|
|
|
|
thin_archive $bfdtests
|
|
|
|
thin_archive_with_nested $bfdtests
|
|
|
|
}
|
2014-06-03 15:37:29 +08:00
|
|
|
}
|
2012-11-07 07:45:43 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
symbol_table
|
2004-02-27 19:04:36 +08:00
|
|
|
argument_parsing
|
2009-03-11 12:36:40 +08:00
|
|
|
deterministic_archive
|
2011-05-02 20:47:47 +08:00
|
|
|
delete_an_element
|
|
|
|
move_an_element
|
2016-03-08 01:29:25 +08:00
|
|
|
empty_archive
|
2019-10-30 18:50:23 +08:00
|
|
|
extract_an_element
|
2020-05-23 06:35:14 +08:00
|
|
|
many_files
|
2020-11-03 23:12:47 +08:00
|
|
|
test_add_dependencies
|
2014-06-03 15:37:29 +08:00
|
|
|
|
2016-06-28 20:21:36 +08:00
|
|
|
if { [is_elf_format] && [supports_gnu_unique] } {
|
2010-03-26 09:42:36 +08:00
|
|
|
unique_symbol
|
|
|
|
}
|