]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-elf/dwarf.exp
Run more ld tests when not native
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-elf / dwarf.exp
1 # Expect script for various DWARF tests.
2 # Copyright (C) 2006-2017 Free Software Foundation, Inc.
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
22 #
23 # Written by H.J. Lu (hongjiu.lu@intel.com)
24 #
25
26 # Exclude non-ELF targets.
27
28 if ![is_elf_format] {
29 return
30 }
31
32 # Check if compiler works
33 if { [which $CC] == 0 } {
34 return
35 }
36
37 # Skip if -feliminate-dwarf2-dups isn't supported.
38 if ![ld_compile "$CC -g -feliminate-dwarf2-dups" $srcdir/$subdir/dummy.c tmpdir/dummy.o] {
39 return
40 }
41
42 set build_tests {
43 {"Build libdwarf1.so"
44 "-s -shared" "-fPIC -g -feliminate-dwarf2-dups"
45 {dwarf1.c} {} "libdwarf1.so"}
46 }
47
48 set run_tests {
49 {"Run with libdwarf1.so first"
50 "-Wl,--no-as-needed tmpdir/libdwarf1.so" ""
51 {dwarf1main.c} "dwarf1a" "dwarf1.out"
52 "-g -feliminate-dwarf2-dups"}
53 {"Run with libdwarf1.so last"
54 "tmpdir/dwarf1main.o tmpdir/libdwarf1.so" ""
55 {dummy.c} "dwarf1b" "dwarf1.out"
56 "-g -feliminate-dwarf2-dups"}
57 }
58
59 run_cc_link_tests $build_tests
60 run_ld_link_exec_tests $run_tests
61
62 proc strip_test {} {
63 global ld
64 global strip
65 global NM
66
67 set test "libdwarf1c.so"
68 set test_name "Strip -s $test"
69 set prog $strip
70
71 if ![ld_link $ld tmpdir/$test "-shared tmpdir/dwarf1.o"] {
72 unresolved "$test_name"
73 return
74 }
75
76 send_log "$NM -D tmpdir/$test > tmpdir/$test.exp\n"
77 catch "exec $NM -D tmpdir/$test > tmpdir/$test.exp" got
78 if ![string match "" $got] then {
79 send_log "$got\n"
80 unresolved "$test_name"
81 return
82 }
83
84 send_log "$prog -s tmpdir/$test\n"
85 catch "exec $prog -s tmpdir/$test" got
86 if ![string match "" $got] then {
87 send_log "$got\n"
88 fail "$test_name"
89 return
90 }
91
92 send_log "$NM -D tmpdir/$test > tmpdir/$test.out\n"
93 catch "exec $NM -D tmpdir/$test > tmpdir/$test.out" got
94 if ![string match "" $got] then {
95 send_log "$got\n"
96 unresolved "$test_name"
97 return
98 }
99
100 if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then {
101 send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n"
102 fail "$test_name"
103 return
104 }
105
106 pass "$test_name"
107 }
108
109 strip_test