Commit | Line | Data |
---|---|---|
738844c1 ILT |
1 | # Test that the linker reports undefined symbol errors correctly. |
2 | # By Ian Lance Taylor, Cygnus Support | |
3 | # | |
4 | # Copyright (C) 1995 Free Software Foundation | |
5 | # | |
6 | # This file 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
19 | ||
20 | set testund "undefined" | |
21 | set testfn "undefined function" | |
22 | set testline "undefined line" | |
23 | ||
ba7db991 ILT |
24 | if { [which $CC] == 0 } { |
25 | untested $testund | |
26 | untested $testfn | |
27 | untested $testline | |
28 | return | |
29 | } | |
30 | ||
738844c1 ILT |
31 | if ![ld_compile "$CC -g" $srcdir$subdir/undefined.c tmpdir/undefined.o] { |
32 | unresolved $testund | |
33 | unresolved $testfn | |
34 | unresolved $testline | |
35 | return | |
36 | } | |
37 | ||
38 | catch "exec rm -f tmpdir/undefined" exec_output | |
39 | ||
ba7db991 ILT |
40 | # Using -e start prevents the SunOS linker from trying to build a |
41 | # shared library. | |
42 | send_log "$ld -e start -o tmpdir/undefined tmpdir/undefined.o\n" | |
43 | verbose "$ld -e start -o tmpdir/undefined tmpdir/undefined.o" | |
738844c1 | 44 | |
ba7db991 | 45 | catch "exec $ld -e start -o tmpdir/undefined tmpdir/undefined.o" exec_output |
738844c1 ILT |
46 | send_log "$exec_output\n" |
47 | verbose "$exec_output" | |
48 | ||
49 | proc checkund { string testname } { | |
50 | global exec_output | |
51 | ||
52 | if [string match "*$string*" $exec_output] { | |
53 | pass $testname | |
54 | } else { | |
55 | fail $testname | |
56 | } | |
57 | } | |
58 | ||
59 | set mu "undefined reference to `this_function_is_not_defined'" | |
60 | checkund $mu $testund | |
61 | ||
ba7db991 ILT |
62 | # ARM PE defaults to using stabs debugging, which we can't handle for |
63 | # a COFF file. | |
64 | setup_xfail "arm*-*-pe*" | |
65 | ||
738844c1 ILT |
66 | set mf "tmpdir/undefined.o: In function `function':" |
67 | checkund $mf $testfn | |
68 | ||
ba7db991 ILT |
69 | # COFF SH gets this test wrong--it reports line 10, because although |
70 | # the jump is at line 9, the function address, and the reloc, is | |
71 | # stored at the end of the function. | |
72 | setup_xfail "sh-*-*" | |
73 | ||
74 | # ARM PE defaults to using stabs debugging, which we can't handle for | |
75 | # a COFF file. | |
76 | setup_xfail "arm*-*-pe*" | |
738844c1 ILT |
77 | |
78 | set ml "undefined.c:9: undefined reference to `this_function_is_not_defined'" | |
79 | checkund $ml $testline |