]>
Commit | Line | Data |
---|---|---|
92b7c7b6 | 1 | # Expect script for various DWARF tests. |
d87bef3a | 2 | # Copyright (C) 2006-2023 Free Software Foundation, Inc. |
92b7c7b6 | 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 | |
92b7c7b6 | 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 |
92b7c7b6 L |
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 | |
f96b4a7b NC |
18 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
19 | # MA 02110-1301, USA. | |
92b7c7b6 L |
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 | ||
47523653 AM |
32 | # Skip targets where -shared is not supported |
33 | ||
34 | if ![check_shared_lib_support] { | |
35 | return | |
36 | } | |
37 | ||
92b7c7b6 | 38 | # Check if compiler works |
44ed8092 | 39 | if { ![check_compiler_available] } { |
92b7c7b6 L |
40 | return |
41 | } | |
42 | ||
43 | # Skip if -feliminate-dwarf2-dups isn't supported. | |
ad77db1c | 44 | if ![ld_compile "$CC_FOR_TARGET -g -feliminate-dwarf2-dups" $srcdir/$subdir/dummy.c tmpdir/dummy.o] { |
92b7c7b6 L |
45 | return |
46 | } | |
47 | ||
48 | set build_tests { | |
49 | {"Build libdwarf1.so" | |
50 | "-s -shared" "-fPIC -g -feliminate-dwarf2-dups" | |
51 | {dwarf1.c} {} "libdwarf1.so"} | |
90ed9b8b AB |
52 | {"DWARF parse during linker error" |
53 | "" "-fno-toplevel-reorder" | |
54 | {dwarf2a.c dwarf2b.c} {{error_output "dwarf2.err"}} "dwarf2.x"} | |
55 | {"Handle no DWARF information" | |
56 | "" "-g0" | |
57 | {dwarf3.c} {{error_output "dwarf3.err"}} "dwarf3.x"} | |
92b7c7b6 L |
58 | } |
59 | ||
60 | set run_tests { | |
61 | {"Run with libdwarf1.so first" | |
d9816402 | 62 | "-Wl,--no-as-needed tmpdir/libdwarf1.so" "" |
92b7c7b6 L |
63 | {dwarf1main.c} "dwarf1a" "dwarf1.out" |
64 | "-g -feliminate-dwarf2-dups"} | |
65 | {"Run with libdwarf1.so last" | |
66 | "tmpdir/dwarf1main.o tmpdir/libdwarf1.so" "" | |
67 | {dummy.c} "dwarf1b" "dwarf1.out" | |
68 | "-g -feliminate-dwarf2-dups"} | |
69 | } | |
70 | ||
42afa120 | 71 | # Disable all sanitizers. |
ad77db1c AM |
72 | set old_CFLAGS "$CFLAGS_FOR_TARGET" |
73 | append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS" | |
92b7c7b6 | 74 | run_cc_link_tests $build_tests |
982c6f26 | 75 | run_ld_link_exec_tests $run_tests |
ad77db1c | 76 | set CFLAGS_FOR_TARGET "$old_CFLAGS" |
92b7c7b6 L |
77 | |
78 | proc strip_test {} { | |
79 | global ld | |
80 | global strip | |
81 | global NM | |
82 | ||
83 | set test "libdwarf1c.so" | |
84 | set test_name "Strip -s $test" | |
85 | set prog $strip | |
86 | ||
d9816402 | 87 | if ![ld_link $ld tmpdir/$test "-shared tmpdir/dwarf1.o"] { |
5b1f6c95 | 88 | fail "$test_name" |
92b7c7b6 L |
89 | return |
90 | } | |
91 | ||
92 | send_log "$NM -D tmpdir/$test > tmpdir/$test.exp\n" | |
93 | catch "exec $NM -D tmpdir/$test > tmpdir/$test.exp" got | |
94 | if ![string match "" $got] then { | |
95 | send_log "$got\n" | |
5b1f6c95 | 96 | fail "$test_name" |
92b7c7b6 L |
97 | return |
98 | } | |
99 | ||
100 | send_log "$prog -s tmpdir/$test\n" | |
101 | catch "exec $prog -s tmpdir/$test" got | |
102 | if ![string match "" $got] then { | |
103 | send_log "$got\n" | |
104 | fail "$test_name" | |
105 | return | |
106 | } | |
107 | ||
108 | send_log "$NM -D tmpdir/$test > tmpdir/$test.out\n" | |
109 | catch "exec $NM -D tmpdir/$test > tmpdir/$test.out" got | |
110 | if ![string match "" $got] then { | |
111 | send_log "$got\n" | |
5b1f6c95 | 112 | fail "$test_name" |
92b7c7b6 L |
113 | return |
114 | } | |
115 | ||
116 | if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then { | |
117 | send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n" | |
118 | fail "$test_name" | |
119 | return | |
120 | } | |
121 | ||
122 | pass "$test_name" | |
123 | } | |
124 | ||
125 | strip_test |