1 # Expect script
for linker support of size relocations.
3 # Copyright
(C
) 2013-2019 Free Software Foundation
, Inc.
5 # This file is part of the GNU Binutils.
7 # This
program is free software
; you can redistribute it and
/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation
; either version
3 of the License
, or
10 #
(at your option
) any later version.
12 # This
program is distributed in the hope that it will be useful
,
13 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License
for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this
program; if not
, write to the Free Software
19 # Foundation
, Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
,
24 # Size relocations have only been implemented
for the ix86 and x86_64
,
26 if {!(([istarget
"i?86-*-*"]
27 ||
[istarget
"x86_64-*-*"])
28 && ([istarget
"*-*-elf*"]
29 ||
[istarget
"*-*-nacl*"]
30 ||
[istarget
"*-*-linux*"]
31 ||
[istarget
"*-*-gnu*"])) } {
32 verbose
"Size relocations tests not run - no target support"
36 # So as to avoid rewriting
every last test case here in a nacl variant
,
37 # we use black magic to massage the generic cases into nacl
-variant cases.
38 if [istarget
"*-*-nacl*"] {
39 # Change all the
-melf_i386 to
-melf_i386_nacl so linking can succeed.
40 set options_regsub
(ld) {-m
(\\S
+) -m
\\1_nacl
}
43 set test_list
[lsort
[glob
-nocomplain $srcdir
/$subdir
/*.d
]]
44 foreach t $test_list
{
45 # We need to
strip the
".d", but can leave the dirname.
46 verbose
[file rootname $t
]
47 run_dump_test
[file rootname $t
]
50 # We need a working compiler.
51 if { ![check_compiler_available
] } {
52 verbose
"Native size relocation tests not run - no compiler available"
56 # Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS
if non
-PIE is required.
57 global NOPIE_CFLAGS NOPIE_LDFLAGS
59 run_cc_link_tests
[list \
61 "Build libsize-1.so" \
64 {size
-1a.c size
-1b.c
} \
69 "Build libsize-2.so" \
72 {size
-2a.c size
-2b.c
} \
77 "Build libsize-3a.so" \
84 "Build libsize-3b.so" \
92 "Build libsize-3c.so" \
100 "Build libsize-6b.so" \
108 "Build libsize-7.so" \
117 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libsize-7.so" \
120 {{readelf
-rW size
-7.rd
}} \
124 "Build libsize-8.so" \
132 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libsize-8.so" \
135 {{readelf
-rW size
-8.rd
}} \
139 "Build libsize-9.so" \
143 {{readelf
-rW size
-9.rd
}} \
147 "Build libsize-10.so" \
151 {{readelf
-rW size
-10.rd
}} \
156 # Check
if size relocation works at run
-time.
157 catch
"exec tmpdir/size-7.exe > tmpdir/dump.out" exec_output
158 if ![string match
"" $exec_output] then {
159 send_log
"No run-time size relocation support: $exec_output\n"
160 verbose
"No run-time size relocation support: $exec_output" 1
164 if { [regexp_diff
"tmpdir/dump.out" "$srcdir/$subdir/size-7.out" ] } then {
165 verbose
"output is [file_contents "tmpdir/dump.out"]" 2
166 fail
"Run-time size relocation"
170 # Run
-time size relocation tests.
171 run_ld_link_exec_tests
[list \
174 "-Wl,--no-as-needed tmpdir/libsize-1.so" \
182 "-Wl,--no-as-needed tmpdir/libsize-2.so" \
192 {size
-3.c size
-3a.c
} \
198 "-Wl,--no-as-needed tmpdir/libsize-3a.so" \
208 {size
-3.c size
-3b.c
} \
214 "-Wl,--no-as-needed tmpdir/libsize-3b.so" \
224 {size
-3.c size
-3c.c
} \
230 "-Wl,--no-as-needed tmpdir/libsize-3c.so" "" \
231 {size
-3.c
} "size-3e" "size-3.out"} \
237 {size
-4a.c size
-4b.c
} \
246 {size
-4b.c size
-4a.c
} \
255 {size
-5a.c size
-5b.c
} \
264 {size
-5b.c size
-5a.c
} \
271 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libsize-6b.so" \
280 "$NOPIE_LDFLAGS -Wl,--no-as-needed,--hash-styl=gnu \
281 tmpdir
/libsize
-8.so
" \
290 "-Wl,--no-as-needed tmpdir/libsize-9.so" \
298 "-Wl,--no-as-needed tmpdir/libsize-10.so" \