2021-01-01 06:58:58 +08:00
|
|
|
# Copyright (C) 1993-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.
|
2012-11-28 01:26:11 +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.
|
2012-11-28 01:26:11 +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
|
|
|
|
|
|
|
|
# This file was written by Rob Savoye <rob@cygnus.com>
|
|
|
|
# and extended by Ian Lance Taylor <ian@cygnus.com>
|
|
|
|
|
2010-11-20 23:36:10 +08:00
|
|
|
proc load_common_lib { name } {
|
|
|
|
load_lib $name
|
|
|
|
}
|
|
|
|
|
|
|
|
load_common_lib binutils-common.exp
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
proc binutil_version { prog } {
|
|
|
|
if ![is_remote host] {
|
2004-05-12 11:28:46 +08:00
|
|
|
set path [which $prog]
|
1999-05-03 15:29:11 +08:00
|
|
|
if {$path == 0} then {
|
|
|
|
perror "$prog can't be run, file not found."
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
set path $prog
|
|
|
|
}
|
2004-05-12 11:28:46 +08:00
|
|
|
set state [remote_exec host $prog --version]
|
|
|
|
set tmp "[lindex $state 1]\n"
|
1999-05-03 15:29:11 +08:00
|
|
|
# Should find a way to discard constant parts, keep whatever's
|
|
|
|
# left, so the version string could be almost anything at all...
|
|
|
|
regexp "\[^\n\]* (cygnus-|)(\[-0-9.a-zA-Z-\]+)\[\r\n\].*" "$tmp" version cyg number
|
|
|
|
if ![info exists number] then {
|
|
|
|
return "$path (no version number)\n"
|
|
|
|
}
|
|
|
|
return "$path $number\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# default_binutils_run
|
|
|
|
# run a program, returning the output
|
|
|
|
# sets binutils_run_failed if the program does not exist
|
2018-02-05 22:00:21 +08:00
|
|
|
# sets binutils_run_status to the exit status of the program
|
1999-05-03 15:29:11 +08:00
|
|
|
#
|
|
|
|
proc default_binutils_run { prog progargs } {
|
|
|
|
global binutils_run_failed
|
2018-02-05 22:00:21 +08:00
|
|
|
global binutils_run_status
|
1999-05-03 15:29:11 +08:00
|
|
|
global host_triplet
|
|
|
|
|
|
|
|
set binutils_run_failed 0
|
2018-02-05 22:00:21 +08:00
|
|
|
if [info exists binutils_run_status] {
|
|
|
|
unset binutils_run_status
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
if ![is_remote host] {
|
|
|
|
if {[which $prog] == 0} then {
|
|
|
|
perror "$prog does not exist"
|
|
|
|
set binutils_run_failed 1
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-22 21:42:26 +08:00
|
|
|
# For objdump, automatically translate standard section
|
|
|
|
# names to the targets one, if they are different.
|
|
|
|
set sect_names [get_standard_section_names]
|
|
|
|
if { $sect_names != "" && [string match "*objdump" $prog] } {
|
|
|
|
regsub -- "-j \\.text" $progargs "-j [lindex $sect_names 0]" progargs
|
|
|
|
regsub -- "-j \\.data" $progargs "-j [lindex $sect_names 1]" progargs
|
|
|
|
regsub -- "-j \\.bss" $progargs "-j [lindex $sect_names 2]" progargs
|
|
|
|
}
|
|
|
|
|
2020-08-27 23:25:03 +08:00
|
|
|
# Gotta quote dollar-signs because they get mangled by the
|
|
|
|
# shell otherwise. Since get_standard_section_names returns
|
|
|
|
# quoted section names, we first remove the original quote
|
|
|
|
# and then requote.
|
|
|
|
regsub -all {\\\$} "$progargs" {$} progargs
|
|
|
|
regsub -all {\$} "$progargs" {\$} progargs
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
send_log "$prog $progargs\n"
|
|
|
|
verbose "$prog $progargs"
|
|
|
|
|
|
|
|
set state [remote_exec host $prog $progargs]
|
2018-02-05 22:00:21 +08:00
|
|
|
set binutils_run_status [lindex $state 0]
|
2004-05-12 11:28:46 +08:00
|
|
|
set exec_output [prune_warnings [lindex $state 1]]
|
1999-05-03 15:29:11 +08:00
|
|
|
if {![string match "" $exec_output]} then {
|
|
|
|
send_log "$exec_output\n"
|
|
|
|
verbose "$exec_output"
|
2006-04-11 03:05:31 +08:00
|
|
|
} else {
|
|
|
|
if { [lindex $state 0] != 0 } {
|
|
|
|
set exec_output "$prog exited with status [lindex $state 0]"
|
|
|
|
send_log "$exec_output\n"
|
|
|
|
verbose "$exec_output"
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
return $exec_output
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2010-07-15 03:46:01 +08:00
|
|
|
# default_binutils_assemble_flags
|
1999-05-03 15:29:11 +08:00
|
|
|
# assemble a file
|
|
|
|
#
|
2010-07-15 03:46:01 +08:00
|
|
|
proc default_binutils_assemble_flags { source object asflags } {
|
1999-05-03 15:29:11 +08:00
|
|
|
global srcdir
|
|
|
|
global host_triplet
|
|
|
|
|
|
|
|
# The HPPA assembler syntax is a little different than most, to make
|
|
|
|
# the test source file assemble we need to run it through sed.
|
|
|
|
#
|
|
|
|
# This is a hack in that it won't scale well if other targets need
|
|
|
|
# similar transformations to assemble. We'll generalize the hack
|
|
|
|
# if/when other targets need similar handling.
|
2018-09-17 07:21:24 +08:00
|
|
|
if { [istarget "hppa*-*-*"] \
|
|
|
|
&& ![istarget "*-*-linux*"] \
|
|
|
|
&& ![istarget "*-*-netbsd*" ] } {
|
2000-07-10 22:59:48 +08:00
|
|
|
set sed_file $srcdir/config/hppa.sed
|
|
|
|
send_log "sed -f $sed_file < $source > asm.s\n"
|
|
|
|
verbose "sed -f $sed_file < $source > asm.s"
|
2004-05-12 11:28:46 +08:00
|
|
|
catch "exec sed -f $sed_file < $source > asm.s"
|
1999-05-03 15:29:11 +08:00
|
|
|
set source asm.s
|
|
|
|
}
|
|
|
|
|
2010-07-15 03:46:01 +08:00
|
|
|
set exec_output [target_assemble $source $object $asflags]
|
1999-05-03 15:29:11 +08:00
|
|
|
set exec_output [prune_warnings $exec_output]
|
|
|
|
|
|
|
|
if [string match "" $exec_output] {
|
|
|
|
return 1
|
|
|
|
} else {
|
|
|
|
send_log "$exec_output\n"
|
|
|
|
verbose "$exec_output"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
2003-09-30 08:15:54 +08:00
|
|
|
|
2004-10-24 01:26:36 +08:00
|
|
|
#
|
|
|
|
# exe_ext
|
|
|
|
# Returns target executable extension, if any.
|
|
|
|
#
|
|
|
|
proc exe_ext {} {
|
2006-09-20 19:35:11 +08:00
|
|
|
if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
|
2004-10-24 01:26:36 +08:00
|
|
|
return ".exe"
|
|
|
|
} else {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2006-04-26 21:37:05 +08:00
|
|
|
|
|
|
|
proc verbose_eval { expr { level 1 } } {
|
|
|
|
global verbose
|
|
|
|
if $verbose>$level then { eval verbose "$expr" $level }
|
|
|
|
}
|