testsuite
[platform/upstream/binutils.git] / ld / testsuite / ld-undefined / undefined.exp
index 05df511..008f440 100644 (file)
@@ -1,27 +1,30 @@
 # Test that the linker reports undefined symbol errors correctly.
 # By Ian Lance Taylor, Cygnus Support
 #
-#   Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation
+#   Copyright (C) 1995-2014 Free Software Foundation, Inc.
 #
-# This file is free software; you can redistribute it and/or modify
+# This file is part of the GNU Binutils.
+#
+# This program 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
+# the Free Software Foundation; either version 3 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.
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
 
 set testund "undefined"
 set testfn "undefined function"
 set testline "undefined line"
 
-if { [which $CC] == 0 } {
+if { ![is_remote host] && [which $CC] == 0 } {
     verbose "Could not find C compiler!" 1
     untested $testund
     untested $testfn
@@ -37,16 +40,15 @@ if ![ld_compile "$CC -g" $srcdir/$subdir/undefined.c tmpdir/undefined.o] {
     return
 }
 
-catch "exec rm -f tmpdir/undefined" exec_output
+remote_file host delete "tmpdir/undefined"
 
 set flags [big_or_little_endian]
 
 # Using -e start prevents the SunOS linker from trying to build a
 # shared library.
 send_log "$ld -e start $flags -o tmpdir/undefined tmpdir/undefined.o\n"
-verbose "$ld -e start $flags -o tmpdir/undefined tmpdir/undefined.o"
+set exec_output [run_host_cmd "$ld" "-e start $flags -o tmpdir/undefined tmpdir/undefined.o"]
 
-catch "exec $ld -e start $flags -o tmpdir/undefined tmpdir/undefined.o" exec_output
 send_log "$exec_output\n"
 verbose "$exec_output"
 
@@ -60,42 +62,36 @@ proc checkund { string testname } {
     }
 }
 
-set mu "undefined reference to `this_function_is_not_defined'"
+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*"
-#setup_xfail "thumb*-*-pe*"
 
-# Just doesn't work for PA ELF.  No clue why.
-setup_xfail "hppa*-*-*elf*"
+# For Xtensa on GNU Linux systems (or any other system where PIC code is
+# always used), the address of the undefined function is in a literal pool
+# outside the function, so that both the "undefined function" and "undefined
+# line" tests fail.
+setup_xfail xtensa*-*-linux*
 
-# With dwarf-2, we can't get the function in which the reference
-# occurs; see below.
-setup_xfail "hppa*64*-*-*"
-setup_xfail "mn10300-*-elf"
-setup_xfail "sh-*-*"
-
-set mf "tmpdir/undefined.o: In function `function':"
+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-*-*"
+if ![is_elf_format] {
+    # 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*"
-#setup_xfail "thumb*-*-pe*"
-
-# Just doesn't work for PA ELF.  No clue why.
-setup_xfail "hppa*-*-*elf*"
+    # ARM PE defaults to using stabs debugging, which we can't handle for
+    # a COFF file.
+    #setup_xfail "arm*-*-pe*"
+}
 
-set ml "undefined.c:9: undefined reference to `this_function_is_not_defined'"
-# With targets that use elf/dwarf2, such as the arm-elf and thumb-elf
-# toolchains, the code in bfd/elf.c:_bfd_elf_find_nearest_line() is called
+set ml "undefined.c:9: undefined reference to `*this_function_is_not_defined'"
+# With targets that use elf/dwarf2, such as the arm-elf
+# toolchain, the code in bfd/elf.c:_bfd_elf_find_nearest_line() is called
 # in order to locate the file name/line number where the undefined
 # reference occurs.  Unfortunately this tries to use the dwarf2 debug
 # information held in the .debug_info section.  This section contains a series
@@ -127,10 +123,25 @@ set ml "undefined.c:9: undefined reference to `this_function_is_not_defined'"
 #
 # hence the xfails below.
 
-#setup_xfail arm-*-elf
-#setup_xfail strongarm-*-elf
-#setup_xfail thumb-*-elf
 setup_xfail mcore-*-elf
+setup_xfail mep-*-*
 setup_xfail mips-sgi-irix6*
+setup_xfail "sh64-*-*"
+# Fails for the MSP430 because it uses SYM_DIFF relocs but it does
+# not provide a special_function for handling them.  If optimization
+# is enabled then this test passes because function()'s prologue is
+# eliminated.
+setup_xfail "msp430-*-*"
+
+# The undefined test fails on 31 bit s/390 because the address of the 
+# function `this_function_is_not_defined' is stored in the literal pool of
+# the function. Therefore the line number in the error message is 8 instead
+# of 9. On 64 bit s/390 this works because of the new brasl instruction that
+# doesn't need a literal pool entry.
+#setup_xfail s390-*-*
+
+# See comments above for Xtensa.
+setup_xfail xtensa*-*-linux*
+setup_xfail hppa*64*-*-*
 
 checkund $ml $testline