# Expect script for various ELF tests.
-# Copyright 2006 Free Software Foundation, Inc.
+# Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012
+# 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,
#
# 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
#
# Exclude non-ELF targets.
-if ![is_elf_format] {
+# The following tests require running the executable generated by ld,
+# or enough of a build environment to create a fully linked executable.
+# This is not commonly available when testing a cross-built linker.
+if ![isnative] {
return
}
-# The following tests require running the executable generated by ld.
-if ![isnative] {
+if ![is_elf_format] {
return
}
-# Check if compiler works
+# Check to see if the C compiler works
if { [which $CC] == 0 } {
return
}
{"Build libbar.so"
"-shared" "-fPIC"
{begin.c end.c} {} "libbar.so"}
+ {"Build warn libbar.so"
+ "-shared" "-fPIC"
+ {beginwarn.c end.c} {} "libbarw.so"
+ "C" "^.*\\\): warning: function foo is deprecated$"}
{"Build hidden libbar.so"
"-shared" "-fPIC"
{begin.c endhidden.c} {} "libbarh.so"}
{"Build libdl2a.so with --dynamic-list=dl2.list"
"-shared -Wl,--dynamic-list=dl2.list" "-fPIC"
{dl2.c dl2xxx.c} {} "libdl2a.so"}
+ {"Build libdl2a.so with --dynamic-list=dl2a.list"
+ "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC"
+ {dl2.c dl2xxx.c} {} "libdl2a.so"}
{"Build libdl2a.so with --dynamic-list-data"
"-shared -Wl,--dynamic-list-data" "-fPIC"
{dl2.c dl2xxx.c} {} "libdl2a.so"}
{"Build libdl6d.so with --dynamic-list-data -Bsymbolic"
"-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC"
{dl6.c} {} "libdl6d.so"}
+ {"Build libdata1.so"
+ "-shared" "-fPIC"
+ {data1.c} {} "libdata1.so"}
+ {"Build libdata2.so"
+ "-shared" "-fPIC"
+ {data2.c} {} "libdata2.so"}
+ {"Build libcomm1.o"
+ "-r -nostdlib" ""
+ {comm1.c} {} "libcomm1.o"}
+ {"Build libfunc1.so"
+ "-shared" "-fPIC"
+ {func1.c} {} "libfunc1.so"}
+ {"Build libpr9676-1.a"
+ "" "-fPIC"
+ {pr9676-1.c} {} "libpr9676-1.a"}
+ {"Build libpr9676-2.a"
+ "" "-fPIC"
+ {pr9676-2.c} {} "libpr9676-2.a"}
+ {"Build libpr9676-3.so"
+ "-shared" "-fPIC"
+ {pr9676-3.c} {} "libpr9676-3.so"}
+ {"Build libpr9676-4.so"
+ "-shared" "-fPIC"
+ {pr9676-4.c} {} "libpr9676-4.so"}
+ {"Build libpr9676-4a.so"
+ "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group"
+ "-fPIC"
+ {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"}
+ {"Build libpr9679.so"
+ "-shared" "-fPIC -O0"
+ {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"}
+ {"Build libpr11138-1.so"
+ "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
+ {pr11138-1.c} {} "libpr11138-1.so"}
+ {"Build libpr11138-2.o"
+ "-r -nostdlib" ""
+ {pr11138-2.c} {} "libpr11138-2.o"}
+ {"Build pr13250-1.so"
+ "-shared" "-fPIC"
+ {pr13250-1.c} {} "libpr13250-1.so"}
+ {"Build pr13250-2.so with libpr13250-1.so"
+ "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC"
+ {pr13250-2.c} {} "libpr13250-2.so"}
+ {"Build libpr13250-3.o"
+ "-r -nostdlib" ""
+ {pr13250-3.c} {} "libpr13250-3.o"}
+ {"Build libpr14323-2.so"
+ "-shared" "-fPIC"
+ {pr14323-2.c} {} "libpr14323-2.so"}
}
+run_cc_link_tests $build_tests
+
set run_tests {
{"Run normal with libfoo.so"
"tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" ""
{"Run normal with versioned libfoo.so"
"tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" ""
{main.c} "normalv" "normal.out"}
+ {"Run warn with versioned libfoo.so"
+ "tmpdir/beginwarn.o tmpdir/libfoov.so" ""
+ {main.c} "warn" "warn.out"
+ "" "" "^.*\\\): warning: function foo is deprecated$"}
{"Run protected with versioned libfoo.so"
"tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" ""
{main.c} "protected" "normal.out"}
{"Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so"
"--dynamic-list-data -ldl" ""
{dl6dmain.c} "dl6d1" "dl6b.out"}
+ {"Run with libdata1.so"
+ "tmpdir/libdata1.so" ""
+ {dynbss1.c} "dynbss1" "pass.out"}
+ {"Run with libdata2.so"
+ "tmpdir/libdata2.so" ""
+ {weakdef1.c} "weakdef1" "pass.out"}
+ {"Run with libfunc1.so comm1.o"
+ "tmpdir/libfunc1.so tmpdir/comm1.o" ""
+ {dummy.c} "comm1" "pass.out"}
+ {"Run with comm1.o libfunc1.so"
+ "tmpdir/comm1.o tmpdir/libfunc1.so" ""
+ {dummy.c} "comm1" "pass.out"}
+ {"Run with pr11138-2.c libpr11138-1.so"
+ "--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" ""
+ {dummy.c} "pr11138a" "pr11138.out"}
+ {"Run with libpr11138-1.so pr11138-2.c"
+ "--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" ""
+ {dummy.c} "pr11138b" "pr11138.out"}
+ {"Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so"
+ "--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" ""
+ {dummy.c} "pr13250" "pass.out"}
+ {"Run with pr14323-1.c pr14323-2.so"
+ "tmpdir/libpr14323-2.so" ""
+ {pr14323-1.c} "pr14323" "pass.out"}
}
-run_cc_link_tests $build_tests
# NetBSD ELF systems do not currently support the .*_array sections.
run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests
-# Check if compiler works
+# Check to see if the C++ compiler works
if { [which $CXX] == 0 } {
return
}
{del.cc new.cc} {} "libnew1b.so" "c++"}
}
+# "-shared -Bsymbolic" only works with gcc 4.5.0 and newer.
+# {"Run with libdl3b.so"
+# "tmpdir/libdl3b.so" ""
+# {dl3main.cc} "dl3b" "dl3b.out" "" "c++"}
set run_cxx_tests {
{"Run with libdl3a.so"
- "tmpdir/libdl3a.so" ""
+ "-Wl,--no-as-needed tmpdir/libdl3a.so" ""
{dl3main.cc} "dl3a" "dl3a.out" "" "c++"}
- {"Run with libdl3b.so"
- "tmpdir/libdl3b.so" ""
- {dl3main.cc} "dl3b" "dl3b.out" "" "c++"}
{"Run with libdl3c.so"
- "tmpdir/libdl3c.so" ""
+ "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
{dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
{"Run with libnew1a.so"
"tmpdir/libnew1a.so" ""