Commit | Line | Data |
---|---|---|
ac69cbc6 | 1 | # Expect script for ld-gc tests |
b90efa5b | 2 | # Copyright (C) 2008-2015 Free Software Foundation, Inc. |
ac69cbc6 TG |
3 | # |
4 | # This file is part of the GNU Binutils. | |
5 | # | |
6 | # This program is free software; you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation; either version 3 of the License, or | |
9 | # (at your option) any later version. | |
10 | # | |
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. | |
15 | # | |
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 | |
18 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
19 | # MA 02110-1301, USA. | |
20 | ||
21 | # These tests require --gc-sections | |
22 | if ![check_gc_sections_available] { | |
23 | return | |
24 | } | |
25 | ||
26 | set cflags "-ffunction-sections -fdata-sections" | |
27 | set objfile "tmpdir/gc.o" | |
28 | ||
2893311c AM |
29 | if [istarget powerpc64*-*-*] { |
30 | # otherwise with -mcmodel=medium gcc we get XPASSes. | |
31 | set cflags "$cflags -mminimal-toc" | |
32 | } | |
33 | ||
6927f982 NC |
34 | if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] } { |
35 | # Otherwise tests FAIL due to _.frame | |
36 | set cflags "$cflags -fomit-frame-pointer -mshort" | |
37 | } | |
38 | ||
d053948a | 39 | if { [is_remote host] || [which $CC] != 0 } { |
3becfab9 HPN |
40 | ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/gc.c $objfile |
41 | } | |
ac69cbc6 TG |
42 | |
43 | proc test_gc { testname filename linker ldflags} { | |
44 | global nm | |
45 | global srcdir | |
46 | global subdir | |
47 | global nm_output | |
48 | global objfile | |
49 | ||
3becfab9 HPN |
50 | if ![file readable $objfile ] { |
51 | untested $testname | |
52 | return | |
53 | } | |
54 | ||
ac69cbc6 | 55 | set outfile "tmpdir/$filename" |
1b662205 AM |
56 | set options "-L$srcdir/$subdir" |
57 | append options " " $ldflags " " [ld_simple_link_defsyms] " " $objfile | |
ac69cbc6 | 58 | |
22fe6da0 KK |
59 | # SH64 targets needs an extra ld option for this test. |
60 | if [istarget sh64*-*-*] { | |
61 | if [istarget sh64*l*-*-*] { | |
62 | set options "-mshlelf32 $options" | |
63 | } else { | |
64 | set options "-mshelf32 $options" | |
65 | } | |
66 | } | |
67 | ||
68 | if ![ld_simple_link $linker $outfile $options] { | |
0d600a79 | 69 | fail $testname |
ac69cbc6 TG |
70 | return |
71 | } | |
72 | if ![ld_nm $nm "" $outfile] { | |
73 | unresolved $testname | |
74 | return | |
75 | } | |
76 | if {![info exists nm_output(used_func)] \ | |
77 | || ![info exists nm_output(used_var)]} { | |
78 | send_log "used sections do not exist\n" | |
79 | verbose "used sections do not exist" | |
80 | fail $testname | |
81 | return | |
82 | } | |
0d600a79 AM |
83 | #ppc64_elf_gc_mark_hook needs to be taught how to look through |
84 | #the .toc section to properly mark variable sections for gc. | |
85 | setup_xfail "powerpc64*-*-*" | |
ac69cbc6 TG |
86 | if {[info exists nm_output(unused_func)] \ |
87 | || [info exists nm_output(unused_var)]} { | |
88 | send_log "unused section still here\n" | |
89 | verbose "unused section still here" | |
90 | fail $testname | |
91 | return | |
92 | } | |
93 | pass $testname | |
94 | } | |
95 | ||
96 | test_gc "Check --gc-section" "gcexe" $ld "--gc-sections -e main" | |
97 | test_gc "Check --gc-section/-q" "gcrexe" $ld "--gc-sections -q -e main" | |
98 | test_gc "Check --gc-section/-r/-e" "gcrel" $ld "-r --gc-sections -e main" | |
99 | test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func" | |
100 | ||
101 | run_dump_test "noent" | |
16583161 | 102 | run_dump_test "abi-note" |
bde6f3eb | 103 | run_dump_test "start" |
d422d1c4 SKS |
104 | if { [is_elf_format] } then { |
105 | run_dump_test "all-debug-sections" | |
106 | } | |
1d5316ab AM |
107 | |
108 | if { [is_elf_format] && [check_shared_lib_support] } then { | |
109 | set gasopt "" | |
110 | if { [istarget tic6x-*] } then { | |
111 | set gasopt "-mpic -mpid=near" | |
112 | } | |
113 | if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/libpersonality.s tmpdir/libpersonality.o] | |
114 | || ![ld_simple_link $ld tmpdir/libpersonality.so "-shared tmpdir/libpersonality.o"] } then { | |
115 | fail libpersonality | |
116 | } else { | |
117 | run_dump_test "personality" | |
118 | } | |
11e6e4c7 | 119 | run_dump_test "pr18223" |
1d5316ab AM |
120 | } |
121 | ||
98da7939 | 122 | if { [is_remote host] || [which $CC] != 0 } { |
5940a93c | 123 | if { [istarget "*-*-linux*"] |
5a68afcf | 124 | || [istarget "*-*-nacl*"] |
5940a93c | 125 | || [istarget "*-*-gnu*"] } { |
98da7939 L |
126 | ld_compile "$CC -fPIC $CFLAGS $cflags" $srcdir/$subdir/pr11218-1.c tmpdir/pr11218-1.o |
127 | ld_simple_link $ld tmpdir/pr11218-1.so "-shared tmpdir/pr11218-1.o" | |
128 | ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/pr11218-2.c tmpdir/pr11218-2.o | |
129 | run_dump_test "pr11218" | |
130 | } | |
131 | } | |
2aa9aad9 NC |
132 | |
133 | if { [is_remote host] || [which $CC] != 0 } { | |
134 | ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o | |
135 | run_dump_test "pr13683" | |
136 | } | |
b9b2ae8b NC |
137 | |
138 | if { [is_remote host] || [which $CC] != 0 } { | |
139 | ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o | |
140 | run_dump_test "pr14265" | |
141 | } |