]>
Commit | Line | Data |
---|---|---|
24718e3b | 1 | # Expect script for binutils tests |
5a68afcf | 2 | # Copyright 2006, 2007, 2008, 2009, 2010, 2012 Free Software Foundation, Inc. |
24718e3b | 3 | # |
f96b4a7b NC |
4 | # This file is part of the GNU Binutils. |
5 | # | |
6 | # This program is free software; you can redistribute it and/or modify | |
24718e3b | 7 | # it under the terms of the GNU General Public License as published by |
f96b4a7b | 8 | # the Free Software Foundation; either version 3 of the License, or |
24718e3b | 9 | # (at your option) any later version. |
f96b4a7b | 10 | # |
24718e3b L |
11 | # This program is distributed in the hope that it will be useful, |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
f96b4a7b | 15 | # |
24718e3b L |
16 | # You should have received a copy of the GNU General Public License |
17 | # along with this program; if not, write to the Free Software | |
f96b4a7b NC |
18 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
19 | # MA 02110-1301, USA. | |
24718e3b L |
20 | # |
21 | # Written by H.J. Lu (hongjiu.lu@intel.com) | |
22 | # | |
23 | ||
24 | # Make sure that binutils can correctly handle ld output in ELF. | |
25 | ||
5940a93c | 26 | if { ![istarget *-*-linux*] |
5a68afcf | 27 | && ![istarget *-*-nacl*] |
5940a93c | 28 | && ![istarget *-*-gnu*]} { |
24718e3b L |
29 | return |
30 | } | |
31 | ||
1224efb8 L |
32 | if { [istarget *-*-linux*aout*] |
33 | || [istarget *-*-linux*oldld*] } { | |
34 | return | |
35 | } | |
36 | ||
37 | proc binutils_test { prog_name ld_options test } { | |
24718e3b L |
38 | global as |
39 | global ld | |
40 | global READELF | |
1224efb8 | 41 | global objcopy |
24718e3b L |
42 | global strip |
43 | global srcdir | |
44 | global subdir | |
1224efb8 L |
45 | global link_output |
46 | ||
47 | eval set prog \$$prog_name | |
48 | set test_name "$prog_name $ld_options ($test)" | |
24718e3b L |
49 | |
50 | if { ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o ] } { | |
1224efb8 | 51 | unresolved "$test_name" |
24718e3b L |
52 | return |
53 | } | |
54 | ||
55 | if { ![ld_simple_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } { | |
1224efb8 | 56 | if { [string match "*not supported*" $link_output] |
3b80b9ce L |
57 | || [string match "*unrecognized option*" $link_output] |
58 | || [string match "*-z relro ignored*" $link_output] } { | |
1224efb8 L |
59 | unsupported "$ld_options is not supported by this target" |
60 | } else { | |
61 | unresolved "$test_name" | |
62 | } | |
24718e3b L |
63 | return |
64 | } | |
65 | ||
66 | send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.exp\n" | |
7f6a71ff JM |
67 | set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.exp"] |
68 | if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { | |
24718e3b | 69 | send_log "$got\n" |
1224efb8 | 70 | unresolved "$test_name" |
24718e3b L |
71 | return |
72 | } | |
73 | ||
1224efb8 | 74 | send_log "$prog tmpdir/$test\n" |
7f6a71ff JM |
75 | set got [remote_exec host "$prog tmpdir/$test"] |
76 | if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { | |
24718e3b | 77 | send_log "$got\n" |
1224efb8 | 78 | fail "$test_name" |
24718e3b L |
79 | return |
80 | } | |
81 | ||
82 | send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.out\n" | |
7f6a71ff JM |
83 | set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"] |
84 | if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { | |
24718e3b | 85 | send_log "$got\n" |
1224efb8 | 86 | unresolved "$test_name" |
24718e3b L |
87 | return |
88 | } | |
89 | ||
90 | if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then { | |
91 | send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n" | |
1224efb8 | 92 | fail "$test_name" |
24718e3b L |
93 | return |
94 | } | |
95 | ||
1224efb8 | 96 | pass "$test_name" |
24718e3b L |
97 | } |
98 | ||
1224efb8 L |
99 | binutils_test strip "-z max-page-size=0x200000" maxpage1 |
100 | binutils_test strip "-z max-page-size=0x200000 -z common-page-size=0x100000" maxpage1 | |
101 | binutils_test strip "-z max-page-size=0x100000" maxpage1 | |
102 | binutils_test strip "-z max-page-size=0x100000 -z common-page-size=0x1000" maxpage1 | |
103 | ||
104 | binutils_test strip "" maxpage1 | |
105 | binutils_test strip "-shared" maxpage1 | |
106 | binutils_test objcopy "" maxpage1 | |
107 | binutils_test objcopy "-shared" maxpage1 | |
108 | ||
f33cfcaa L |
109 | binutils_test strip "-z relro" relro1 |
110 | binutils_test strip "-z relro -shared" relro1 | |
111 | binutils_test objcopy "-z relro" relro1 | |
112 | binutils_test objcopy "-z relro -shared" relro1 | |
5a68afcf | 113 | if { ([istarget "i?86-*-elf*"] |
99753d9d AM |
114 | || (([istarget "i?86-*-linux*"] |
115 | || [istarget "i?86-*-gnu*"]) | |
b10a8ae0 L |
116 | && ![istarget "*-*-*aout*"] |
117 | && ![istarget "*-*-*oldld*"]) | |
118 | || [istarget "x86_64-*-linux*"] | |
5a68afcf RM |
119 | || [istarget "amd64-*-linux*"] |
120 | || [istarget "i?86-*nacl*"] | |
121 | || [istarget "x86_64-*nacl*"]) } { | |
b10a8ae0 L |
122 | binutils_test strip "-z relro -shared" relro2 |
123 | binutils_test objcopy "-z relro -shared" relro2 | |
124 | } | |
c9df6640 | 125 | |
b26238c0 AM |
126 | binutils_test strip "-T ${srcdir}/${subdir}/lma.lnk" lma |
127 | ||
3bd61671 | 128 | set tls_tests { "tdata1" "tdata2" } |
de5c4ae2 AM |
129 | # hppa64 has its own .tbss section, with different flags. |
130 | if { ![istarget "hppa64-*-*"] } { | |
3bd61671 | 131 | lappend tls_tests "tdata3" "tbss1" "tbss2" "tbss3" |
de5c4ae2 | 132 | } |
67e9eb74 AM |
133 | set tls_opts { |
134 | "" | |
135 | "-z relro" | |
136 | "-shared" | |
137 | "-shared -z relro" | |
138 | "-z max-page-size=0x100000" | |
139 | "-z max-page-size=0x100000 -z common-page-size=0x1000" | |
de5c4ae2 | 140 | } |
b10a8ae0 | 141 | |
67e9eb74 AM |
142 | foreach testitem $tls_tests { |
143 | foreach testopt $tls_opts { | |
f33cfcaa | 144 | binutils_test objcopy $testopt $testitem |
67e9eb74 AM |
145 | } |
146 | } |