summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/binutils/ld/testsuite/ld-undefined/undefined.exp
blob: 208d679f6c16c6d26bfe92b74e25087849702c21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Test that the linker reports undefined symbol errors correctly.
# By Ian Lance Taylor, Cygnus Support
#
#   Copyright (C) 1995 Free Software Foundation
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

set testund "undefined"
set testfn "undefined function"
set testline "undefined line"

if { [which $CC] == 0 } {
    untested $testund
    untested $testfn
    untested $testline
    return
}

if ![ld_compile "$CC -g" $srcdir$subdir/undefined.c tmpdir/undefined.o] {
    unresolved $testund
    unresolved $testfn
    unresolved $testline
    return
}

catch "exec rm -f tmpdir/undefined" exec_output

# Using -e start prevents the SunOS linker from trying to build a
# shared library.
send_log "$ld -e start -o tmpdir/undefined tmpdir/undefined.o\n"
verbose "$ld -e start -o tmpdir/undefined tmpdir/undefined.o"

catch "exec $ld -e start -o tmpdir/undefined tmpdir/undefined.o" exec_output
send_log "$exec_output\n"
verbose "$exec_output"

proc checkund { string testname } {
    global exec_output

    if [string match "*$string*" $exec_output] {
	pass $testname
    } else {
	fail $testname
    }
}

set mu "undefined reference to `this_function_is_not_defined'"
checkund $mu $testund

# ARM PE defaults to using stabs debugging, which we can't handle for
# a COFF file.
setup_xfail "arm*-*-pe*"

# Just doesn't work for PA ELF.  No clue why.
setup_xfail "hppa*-*-*elf*"

set mf "tmpdir/undefined.o: In function `function':"
checkund $mf $testfn

# COFF SH gets this test wrong--it reports line 10, because although
# the jump is at line 9, the function address, and the reloc, is
# stored at the end of the function.
setup_xfail "sh-*-*"

# ARM PE defaults to using stabs debugging, which we can't handle for
# a COFF file.
setup_xfail "arm*-*-pe*"

# Just doesn't work for PA ELF.  No clue why.
setup_xfail "hppa*-*-*elf*"

set ml "undefined.c:9: undefined reference to `this_function_is_not_defined'"
checkund $ml $testline