1 # Expect script for linker support of size relocations.
3 # Copyright 2013 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 relications 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 && ![istarget "*-*-*aout*"]
33 && ![istarget "*-*-*oldld*"]))) } {
34 verbose "Size relocations tests not run - no target support"
38 set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
39 foreach t $test_list {
40 # We need to strip the ".d", but can leave the dirname.
41 verbose [file rootname $t]
42 run_dump_test [file rootname $t]
45 # We need a native system.
47 verbose "Natibe size relocation tests not run - not a native toolchain"
51 # We need a working compiler.
52 if { [which $CC] == 0 } {
53 verbose "Native size relocation tests not run - no compiler available"
60 {size-1a.c size-1b.c} {} "libsize-1.so"}
63 {size-2a.c size-2b.c} {} "libsize-2.so"}
64 {"Build libsize-3a.so"
66 {size-3a.c} {} "libsize-3a.so"}
67 {"Build libsize-3b.so"
69 {size-3b.c} {} "libsize-3b.so"}
70 {"Build libsize-3c.so"
72 {size-3c.c} {} "libsize-3c.so"}
73 {"Build libsize-6b.so"
75 {size-6b.c} {} "libsize-6b.so"}
78 {size-7b.c} {} "libsize-7.so"}
80 "-Wl,--no-as-needed tmpdir/libsize-7.so" ""
81 {size-7a.c} {{readelf -rW size-7.rd}} "size-7.exe"}
84 {size-8b.c} {} "libsize-8.so"}
86 "-Wl,--no-as-needed tmpdir/libsize-8.so" ""
87 {size-8a.c} {{readelf -rW size-8.rd}} "size-8.exe"}
90 {size-9b.c} {{readelf -rW size-9.rd}} "libsize-9.so"}
91 {"Build libsize-10.so"
93 {size-10b.c} {{readelf -rW size-10.rd}} "libsize-10.so"}
96 run_cc_link_tests $build_tests
100 "tmpdir/libsize-1.so" ""
101 {size-1.c} "size-1" "size-1.out"}
103 "tmpdir/libsize-2.so" ""
104 {size-2.c} "size-2" "size-2.out"}
107 {size-3.c size-3a.c} "size-3a" "size-3.out"}
109 "tmpdir/libsize-3a.so" ""
110 {size-3.c} "size-3b" "size-3.out"}
113 {size-3.c size-3b.c} "size-3c" "size-3.out"}
115 "tmpdir/libsize-3b.so" ""
116 {size-3.c} "size-3d" "size-3.out"}
119 {size-3.c size-3c.c} "size-3d" "size-3.out"}
121 "tmpdir/libsize-3c.so" ""
122 {size-3.c} "size-3e" "size-3.out"}
125 {size-4a.c size-4b.c} "size-4a" "size-4.out"}
128 {size-4b.c size-4a.c} "size-4b" "size-4.out"}
131 {size-5a.c size-5b.c} "size-5a" "size-5.out"}
134 {size-5b.c size-5a.c} "size-5b" "size-5.out"}
136 "tmpdir/libsize-6b.so" ""
137 {size-6a.c} "size-6" "size-6.out"}
140 run_ld_link_exec_tests [] $run_tests
142 # Check if size relocation works at run-time.
143 catch "exec tmpdir/size-7.exe > tmpdir/dump.out" exec_output
144 if ![string match "" $exec_output] then {
145 send_log "No run-time size relocation support: $exec_output\n"
146 verbose "No run-time size relocation support: $exec_output" 1
150 if { [regexp_diff "tmpdir/dump.out" "$srcdir/$subdir/size-7.out" ] } then {
151 verbose "output is [file_contents "tmpdir/dump.out"]" 2
152 fail "Run-time size relocation"
156 # Run-time size relocation tests.
159 "tmpdir/libsize-8.so --hash-styl=gnu" ""
160 {size-8a.c} "size-8" "size-8.out"}
162 "tmpdir/libsize-9.so" ""
163 {size-9a.c} "size-9" "size-9.out"}
165 "tmpdir/libsize-10.so" ""
166 {size-10a.c} "size-10" "size-10.out"}
169 run_ld_link_exec_tests [] $run_time_tests