Commit | Line | Data |
---|---|---|
b3adc24a | 1 | # Copyright (C) 1993-2020 Free Software Foundation, Inc. |
252b5132 RH |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
32866df7 | 5 | # the Free Software Foundation; either version 3 of the License, or |
252b5132 RH |
6 | # (at your option) any later version. |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program; if not, write to the Free Software | |
b43b5d5f | 15 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
252b5132 RH |
16 | |
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-dejagnu@prep.ai.mit.edu | |
19 | ||
20 | # This file was written by Rob Savoye. (rob@cygnus.com) | |
21 | ||
252b5132 RH |
22 | load_lib utils-lib.exp |
23 | ||
8ffb70eb AM |
24 | if ![info exists AS] then { |
25 | set AS [findfile $base_dir/../gas/as-new $base_dir/../gas/as-new [transform as]] | |
26 | } | |
27 | if ![info exists ASFLAGS] then { | |
28 | set ASFLAGS "" | |
29 | } | |
30 | ||
33ea299c TP |
31 | if ![info exists LD] then { |
32 | set LD [findfile $base_dir/../ld/ld-new $base_dir/../ld/ld-new [transform ld]] | |
33 | } | |
34 | if ![info exists LDFLAGS] then { | |
35 | set LDFLAGS "" | |
36 | } | |
37 | set ld_elf_shared_opt "-z norelro" | |
38 | ||
252b5132 RH |
39 | if ![info exists NM] then { |
40 | set NM [findfile $base_dir/nm-new $base_dir/nm-new [transform nm]] | |
41 | } | |
42 | if ![info exists NMFLAGS] then { | |
43 | set NMFLAGS "" | |
44 | } | |
252b5132 RH |
45 | if ![info exists SIZE] then { |
46 | set SIZE [findfile $base_dir/size] | |
47 | } | |
48 | if ![info exists SIZEFLAGS] then { | |
49 | set SIZEFLAGS "" | |
50 | } | |
252b5132 RH |
51 | if ![info exists OBJDUMP] then { |
52 | set OBJDUMP [findfile $base_dir/objdump] | |
53 | } | |
54 | if ![info exists OBJDUMPFLAGS] then { | |
55 | set OBJDUMPFLAGS "" | |
56 | } | |
252b5132 RH |
57 | if ![info exists OBJCOPY] then { |
58 | set OBJCOPY [findfile $base_dir/objcopy] | |
59 | } | |
60 | if ![info exists OBJCOPYFLAGS] then { | |
61 | set OBJCOPYFLAGS "" | |
62 | } | |
252b5132 RH |
63 | if ![info exists AR] then { |
64 | set AR [findfile $base_dir/ar] | |
65 | } | |
71f5e3f7 NC |
66 | if ![info exists STRINGS] then { |
67 | set STRINGS [findfile $base_dir/strings] | |
68 | } | |
69 | if ![info exists STRINGSFLAGS] then { | |
70 | set STRINGSFLAGS "" | |
71 | } | |
252b5132 RH |
72 | if ![info exists STRIP] then { |
73 | set STRIP [findfile $base_dir/strip-new $base_dir/strip-new [transform strip]] | |
74 | } | |
75 | if ![info exists STRIPFLAGS] then { | |
76 | set STRIPFLAGS "" | |
77 | } | |
252b5132 RH |
78 | if ![info exists READELF] then { |
79 | set READELF [findfile $base_dir/readelf] | |
80 | } | |
81 | if ![info exists READELFFLAGS] then { | |
82 | set READELFFLAGS "" | |
83 | } | |
30fd33bb L |
84 | if ![info exists ELFEDIT] then { |
85 | set ELFEDIT [findfile $base_dir/elfedit] | |
86 | } | |
87 | if ![info exists ELFEDITFLAGS] then { | |
88 | set ELFEDITFLAGS "" | |
89 | } | |
64e08727 DD |
90 | if ![info exists WINDRES] then { |
91 | set WINDRES [findfile $base_dir/windres] | |
92 | } | |
c9e38879 NC |
93 | if ![info exists DLLTOOL] then { |
94 | set DLLTOOL [findfile $base_dir/dlltool] | |
95 | } | |
af03af8f NC |
96 | if ![info exists CXXFILT] then { |
97 | set CXXFILT [findfile $base_dir/cxxfilt] | |
98 | } | |
99 | if ![info exists CXXFILTFLAGS] then { | |
100 | set CXXFILTFLAGS "" | |
101 | } | |
64e08727 | 102 | |
252b5132 RH |
103 | if ![file isdirectory tmpdir] {catch "exec mkdir tmpdir" status} |
104 | ||
0fd555c4 | 105 | # Make a copy from tmpdir/gas/as and tmpdir/gas/ld to the assembler |
9a580d9a L |
106 | # and linker in the build tree, so that we can use a -B option to gcc |
107 | # to force it to use the newly built assembler/linker. | |
9ab80182 JB |
108 | if {![file isdirectory tmpdir/gas]} {catch "exec mkdir tmpdir/gas" status} |
109 | ||
110 | proc link_or_copy { src dst } { | |
111 | if ![catch "exec ln -sf ../../../$src tmpdir/gas/$dst" status] then {return 0} | |
112 | if ![catch "exec ln -f ../$src tmpdir/gas/$dst" status] then {return 0} | |
113 | catch "exec cp -fpu ../$src tmpdir/gas/$dst" status | |
114 | } | |
115 | ||
116 | if {[file isfile gas/as-new[exe_ext]]} then { | |
117 | link_or_copy gas/as-new[exe_ext] as[exe_ext] | |
118 | } else { | |
119 | # For non-Windows hosts there may be an executable | |
120 | # without a .exe suffix, so try copying that instead. | |
121 | link_or_copy gas/as-new as[exe_ext] | |
122 | } | |
123 | # This may not be needed any more... | |
124 | if {[file isfile ld/ld-new[exe_ext]]} then { | |
125 | link_or_copy ld/ld-new[exe_ext] ld[exe_ext] | |
126 | } else { | |
127 | link_or_copy ld/ld-new ld[exe_ext] | |
9a580d9a | 128 | } |
b67ce46f JM |
129 | if {[file isfile tmpdir/gas/as[exe_ext]]} then { |
130 | set gcc_gas_flag "-B[pwd]/tmpdir/gas/" | |
131 | set dlltool_gas_flag "-S [pwd]/tmpdir/gas/as[exe_ext]" | |
132 | } else { | |
133 | # Testing an installed toolchain. | |
134 | set gcc_gas_flag "" | |
135 | set dlltool_gas_flag "" | |
136 | } | |
9a580d9a | 137 | |
252b5132 RH |
138 | # |
139 | # binutils_run | |
140 | # run a program, returning the output | |
141 | # sets binutils_run_failed if the program does not exist | |
78c88364 | 142 | # sets binutils_run_status to the exit status of the program |
252b5132 RH |
143 | # |
144 | proc binutils_run { prog progargs } { | |
145 | default_binutils_run $prog $progargs | |
146 | } | |
147 | ||
148 | # | |
149 | # binutils_assemble | |
150 | # assemble a file | |
151 | # | |
152 | proc binutils_assemble { source object } { | |
368886ac L |
153 | default_binutils_assemble_flags $source $object "" |
154 | } | |
155 | ||
156 | # | |
157 | # binutils_assemble_flags | |
158 | # assemble a file | |
159 | # | |
160 | proc binutils_assemble_flags { source object asflags } { | |
161 | default_binutils_assemble_flags $source $object $asflags | |
252b5132 | 162 | } |