Add x86 size relocation support to gas
[platform/upstream/binutils.git] / ld / testsuite / ld-size / size.exp
1 # Expect script for linker support of size relocations.
2 #
3 #   Copyright 2013 Free Software Foundation, Inc.
4 #
5 # This file is part of the GNU Binutils.
6 #
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.
11 #
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.
16 #
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,
20 # MA 02110-1301, USA.
21 #
22
23
24 # Size relications have only been implemented for the ix86 and x86_64,
25 # so far.
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"
35     return
36 }
37
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]
43 }
44
45 # We need a native system.
46 if ![isnative] {
47     verbose "Natibe size relocation tests not run - not a native toolchain"
48     return
49 }
50
51 # We need a working compiler.
52 if { [which $CC] == 0 } {
53     verbose "Native size relocation tests not run - no compiler available"
54     return
55 }
56
57 set build_tests {
58   {"Build libsize-3a.so"
59    "-shared" "-fPIC"
60    {size-3a.c} {} "libsize-3a.so"}
61   {"Build libsize-3b.so"
62    "-shared" "-fPIC"
63    {size-3b.c} {} "libsize-3b.so"}
64   {"Build libsize-3c.so"
65    "-shared" "-fPIC"
66    {size-3c.c} {} "libsize-3c.so"}
67   {"Build libsize-6b.so"
68    "-shared" "-fPIC"
69    {size-6b.c} {} "libsize-6b.so"}
70   {"Build libsize-7.so"
71    "-shared" "-fPIC"
72    {size-7b.c} {} "libsize-7.so"}
73   {"Build size-7"
74    "tmpdir/libsize-7.so" ""
75    {size-7a.c} {{readelf -rW size-7.rd}} "size-7.exe"}
76   {"Build libsize-8.so"
77    "-shared" "-fPIC"
78    {size-8b.c} {} "libsize-8.so"}
79   {"Build size-8"
80    "tmpdir/libsize-8.so" ""
81    {size-8a.c} {{readelf -rW size-8.rd}} "size-8.exe"}
82 }
83
84 run_cc_link_tests $build_tests
85
86 set run_tests {
87     {"Run size-3a"
88      "" ""
89      {size-3.c size-3a.c} "size-3a" "size-3.out"}
90     {"Run size-3b"
91      "tmpdir/libsize-3a.so" ""
92      {size-3.c} "size-3b" "size-3.out"}
93     {"Run size-3c"
94      "" ""
95      {size-3.c size-3b.c} "size-3c" "size-3.out"}
96     {"Run size-3d"
97      "tmpdir/libsize-3b.so" ""
98      {size-3.c} "size-3d" "size-3.out"}
99     {"Run size-3d"
100      "" ""
101      {size-3.c size-3c.c} "size-3d" "size-3.out"}
102     {"Run size-3e"
103      "tmpdir/libsize-3c.so" ""
104      {size-3.c} "size-3e" "size-3.out"}
105     {"Run size-4a"
106      "" ""
107      {size-4a.c size-4b.c} "size-4a" "size-4.out"}
108     {"Run size-4b"
109      "" ""
110      {size-4b.c size-4a.c} "size-4b" "size-4.out"}
111     {"Run size-5a"
112      "" ""
113      {size-5a.c size-5b.c} "size-5a" "size-5.out"}
114     {"Run size-5b"
115      "" ""
116      {size-5b.c size-5a.c} "size-5b" "size-5.out"}
117     {"Run size-6"
118      "tmpdir/libsize-6b.so" ""
119      {size-6a.c} "size-6" "size-6.out"}
120 }
121
122 run_ld_link_exec_tests [] $run_tests