This commit was generated by cvs2svn to track changes on a CVS vendor
[external/binutils.git] / ld / testsuite / ld-undefined / undefined.exp
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
24 if { [which $CC] == 0 } {
25     untested $testund
26     untested $testfn
27     untested $testline
28     return
29 }
30
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
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"
44
45 catch "exec $ld -e start -o tmpdir/undefined tmpdir/undefined.o" exec_output
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
62 # ARM PE defaults to using stabs debugging, which we can't handle for
63 # a COFF file.
64 setup_xfail "arm*-*-pe*"
65
66 set mf "tmpdir/undefined.o: In function `function':"
67 checkund $mf $testfn
68
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*"
77
78 set ml "undefined.c:9: undefined reference to `this_function_is_not_defined'"
79 checkund $ml $testline