* ld-undefined/undefined.exp: XFAIL on IRIX6 for the usual as
[binutils.git] / ld / testsuite / ld-undefined / undefined.exp
blob5f551924a3b18f4edf3d06d4c0889b701f3189eb
1 # Test that the linker reports undefined symbol errors correctly.
2 # By Ian Lance Taylor, Cygnus Support
4 # Copyright (C) 1995, 1996, 1997 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 } {
25 verbose "Could not find C compiler!" 1
26 untested $testund
27 untested $testfn
28 untested $testline
29 return
32 if ![ld_compile "$CC -g" $srcdir/$subdir/undefined.c tmpdir/undefined.o] {
33 verbose "Unable to compile test file!" 1
34 unresolved $testund
35 unresolved $testfn
36 unresolved $testline
37 return
40 catch "exec rm -f tmpdir/undefined" exec_output
42 # Using -e start prevents the SunOS linker from trying to build a
43 # shared library.
44 send_log "$ld -e start -o tmpdir/undefined tmpdir/undefined.o\n"
45 verbose "$ld -e start -o tmpdir/undefined tmpdir/undefined.o"
47 catch "exec $ld -e start -o tmpdir/undefined tmpdir/undefined.o" exec_output
48 send_log "$exec_output\n"
49 verbose "$exec_output"
51 proc checkund { string testname } {
52 global exec_output
54 if [string match "*$string*" $exec_output] {
55 pass $testname
56 } else {
57 fail $testname
61 set mu "undefined reference to `this_function_is_not_defined'"
62 checkund $mu $testund
64 # ARM PE defaults to using stabs debugging, which we can't handle for
65 # a COFF file.
66 #setup_xfail "arm*-*-pe*"
67 #setup_xfail "thumb*-*-pe*"
69 # Just doesn't work for PA ELF. No clue why.
70 setup_xfail "hppa*-*-*elf*"
72 set mf "tmpdir/undefined.o: In function `function':"
73 checkund $mf $testfn
75 # COFF SH gets this test wrong--it reports line 10, because although
76 # the jump is at line 9, the function address, and the reloc, is
77 # stored at the end of the function.
78 setup_xfail "sh-*-*"
80 # ARM PE defaults to using stabs debugging, which we can't handle for
81 # a COFF file.
82 #setup_xfail "arm*-*-pe*"
83 #setup_xfail "thumb*-*-pe*"
85 # Just doesn't work for PA ELF. No clue why.
86 setup_xfail "hppa*-*-*elf*"
88 set ml "undefined.c:9: undefined reference to `this_function_is_not_defined'"
89 # With targets that use elf/dwarf2, such as the arm-elf and thumb-elf
90 # toolchains, the code in bfd/elf.c:_bfd_elf_find_nearest_line() is called
91 # in order to locate the file name/line number where the undefined
92 # reference occurs. Unfortunately this tries to use the dwarf2 debug
93 # information held in the .debug_info section. This section contains a series
94 # of comp_unit structures, each of which has a low/high address range
95 # representing the span of memory locations covered by that structure. The
96 # structures also index into other structures held in the .debug_line section
97 # and together they can translate memory locations back into file/function/line
98 # number addresses in the source code. Since the information about the memory
99 # region covered by a comp_unit is only determined at link time, the low/high
100 # addresses in the .debug_info section and the line addresses in the .debug_line
101 # section are computed by generating relocs against known symbols in the object
102 # code.
104 # When the undefined reference is detected, the relocs in the dwarf2
105 # debug sections have not yet been resolved, so the low/high addresses and the
106 # line number address are all set at zero. Thus when _bfd_elf_find_nearest_line()
107 # calls _bfd_dwarf2_find_nearest_line() no comp_unit can be found which
108 # actually covers the address where the reference occured, and so
109 # _bfd_elf_find_nearest_line() fails.
111 # The upshot of all of this, is that the error message reported by the
112 # linker, instead of having a source file name & line number as in:
114 # undefined.c:9: undefined reference to `this_function_is_not_defined'
116 # has an object file & section address instead:
118 # undefined.0(.text+0xc): undefined reference to `this_function_is_not_defined'
120 # hence the xfails below.
122 #setup_xfail arm-*-elf
123 #setup_xfail strongarm-*-elf
124 #setup_xfail thumb-*-elf
125 setup_xfail mcore-*-elf
126 setup_xfail mips-sgi-irix6*
128 checkund $ml $testline