* elf64-ppc.c (ppc64_elf_edit_toc): Don't free toc relocs until
[deliverable/binutils-gdb.git] / ld / testsuite / ld-gc / gc.exp
CommitLineData
ac69cbc6 1# Expect script for ld-gc tests
16583161 2# Copyright 2008, 2009, 2010
ac69cbc6
TG
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
23if ![check_gc_sections_available] {
24 return
25}
26
27set cflags "-ffunction-sections -fdata-sections"
28set objfile "tmpdir/gc.o"
29
d053948a 30if { [is_remote host] || [which $CC] != 0 } {
3becfab9
HPN
31 ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/gc.c $objfile
32}
ac69cbc6
TG
33
34proc test_gc { testname filename linker ldflags} {
35 global nm
36 global srcdir
37 global subdir
38 global nm_output
39 global objfile
40
3becfab9
HPN
41 if ![file readable $objfile ] {
42 untested $testname
43 return
44 }
45
ac69cbc6 46 set outfile "tmpdir/$filename"
1b662205
AM
47 set options "-L$srcdir/$subdir"
48 append options " " $ldflags " " [ld_simple_link_defsyms] " " $objfile
ac69cbc6 49
22fe6da0
KK
50 # SH64 targets needs an extra ld option for this test.
51 if [istarget sh64*-*-*] {
52 if [istarget sh64*l*-*-*] {
53 set options "-mshlelf32 $options"
54 } else {
55 set options "-mshelf32 $options"
56 }
57 }
58
59 if ![ld_simple_link $linker $outfile $options] {
0d600a79 60 fail $testname
ac69cbc6
TG
61 return
62 }
63 if ![ld_nm $nm "" $outfile] {
64 unresolved $testname
65 return
66 }
67 if {![info exists nm_output(used_func)] \
68 || ![info exists nm_output(used_var)]} {
69 send_log "used sections do not exist\n"
70 verbose "used sections do not exist"
71 fail $testname
72 return
73 }
0d600a79
AM
74 #ppc64_elf_gc_mark_hook needs to be taught how to look through
75 #the .toc section to properly mark variable sections for gc.
76 setup_xfail "powerpc64*-*-*"
ac69cbc6
TG
77 if {[info exists nm_output(unused_func)] \
78 || [info exists nm_output(unused_var)]} {
79 send_log "unused section still here\n"
80 verbose "unused section still here"
81 fail $testname
82 return
83 }
84 pass $testname
85}
86
87test_gc "Check --gc-section" "gcexe" $ld "--gc-sections -e main"
88test_gc "Check --gc-section/-q" "gcrexe" $ld "--gc-sections -q -e main"
89test_gc "Check --gc-section/-r/-e" "gcrel" $ld "-r --gc-sections -e main"
90test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func"
91
92run_dump_test "noent"
16583161 93run_dump_test "abi-note"
bde6f3eb 94run_dump_test "start"
98da7939 95if { [is_remote host] || [which $CC] != 0 } {
5940a93c
TS
96 if { [istarget "*-*-linux*"]
97 || [istarget "*-*-gnu*"] } {
98da7939
L
98 ld_compile "$CC -fPIC $CFLAGS $cflags" $srcdir/$subdir/pr11218-1.c tmpdir/pr11218-1.o
99 ld_simple_link $ld tmpdir/pr11218-1.so "-shared tmpdir/pr11218-1.o"
100 ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/pr11218-2.c tmpdir/pr11218-2.o
101 run_dump_test "pr11218"
102 }
103}
This page took 0.210018 seconds and 4 git commands to generate.