Commit | Line | Data |
---|---|---|
ac69cbc6 TG |
1 | # Expect script for ld-gc tests |
2 | # Copyright 2008 | |
3 | # 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 | # These tests require --gc-sections | |
23 | if ![check_gc_sections_available] { | |
24 | return | |
25 | } | |
26 | ||
27 | set cflags "-ffunction-sections -fdata-sections" | |
28 | set objfile "tmpdir/gc.o" | |
29 | ||
30 | ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/gc.c $objfile | |
31 | ||
32 | proc test_gc { testname filename linker ldflags} { | |
33 | global nm | |
34 | global srcdir | |
35 | global subdir | |
36 | global nm_output | |
37 | global objfile | |
38 | ||
39 | set outfile "tmpdir/$filename" | |
40 | ||
41 | if ![ld_simple_link $linker $outfile "-L$srcdir/$subdir $ldflags $objfile"] { | |
42 | fail $testname | |
43 | return | |
44 | } | |
45 | if ![ld_nm $nm "" $outfile] { | |
46 | unresolved $testname | |
47 | return | |
48 | } | |
49 | if {![info exists nm_output(used_func)] \ | |
50 | || ![info exists nm_output(used_var)]} { | |
51 | send_log "used sections do not exist\n" | |
52 | verbose "used sections do not exist" | |
53 | fail $testname | |
54 | return | |
55 | } | |
56 | if {[info exists nm_output(unused_func)] \ | |
57 | || [info exists nm_output(unused_var)]} { | |
58 | send_log "unused section still here\n" | |
59 | verbose "unused section still here" | |
60 | fail $testname | |
61 | return | |
62 | } | |
63 | pass $testname | |
64 | } | |
65 | ||
66 | test_gc "Check --gc-section" "gcexe" $ld "--gc-sections -e main" | |
67 | test_gc "Check --gc-section/-q" "gcrexe" $ld "--gc-sections -q -e main" | |
68 | test_gc "Check --gc-section/-r/-e" "gcrel" $ld "-r --gc-sections -e main" | |
69 | test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func" | |
70 | ||
71 | run_dump_test "noent" |