1 # Test that the linker reports undefined symbol errors correctly.
2 # By Ian Lance Taylor, Cygnus Support
4 # Copyright (C) 1995 Free Software Foundation
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.
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.
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.
20 set testund "undefined"
21 set testfn "undefined function"
22 set testline "undefined line"
24 if { [which $CC] == 0 } {
31 if ![ld_compile "$CC -g" $srcdir$subdir/undefined.c tmpdir/undefined.o] {
38 catch "exec rm -f tmpdir/undefined" exec_output
40 # Using -e start prevents the SunOS linker from trying to build a
42 send_log "$ld -e start -o tmpdir/undefined tmpdir/undefined.o\n"
43 verbose "$ld -e start -o tmpdir/undefined tmpdir/undefined.o"
45 catch "exec $ld -e start -o tmpdir/undefined tmpdir/undefined.o" exec_output
46 send_log "$exec_output\n"
47 verbose "$exec_output"
49 proc checkund { string testname } {
52 if [string match "*$string*" $exec_output] {
59 set mu "undefined reference to `this_function_is_not_defined'"
62 # ARM PE defaults to using stabs debugging, which we can't handle for
64 setup_xfail "arm*-*-pe*"
66 set mf "tmpdir/undefined.o: In function `function':"
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.
74 # ARM PE defaults to using stabs debugging, which we can't handle for
76 setup_xfail "arm*-*-pe*"
78 set ml "undefined.c:9: undefined reference to `this_function_is_not_defined'"
79 checkund $ml $testline