aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ChangeLog27
-rw-r--r--ld/testsuite/ld-elf/dl1.c10
-rw-r--r--ld/testsuite/ld-elf/dl1.list6
-rw-r--r--ld/testsuite/ld-elf/dl1.out1
-rw-r--r--ld/testsuite/ld-elf/dl1main.c33
-rw-r--r--ld/testsuite/ld-elf/dl2.c16
-rw-r--r--ld/testsuite/ld-elf/dl2.list3
-rw-r--r--ld/testsuite/ld-elf/dl2a.out3
-rw-r--r--ld/testsuite/ld-elf/dl2b.out3
-rw-r--r--ld/testsuite/ld-elf/dl2main.c22
-rw-r--r--ld/testsuite/ld-elf/dl2xxx.c7
-rw-r--r--ld/testsuite/ld-elf/dl2xxx.list3
-rw-r--r--ld/testsuite/ld-elf/dl3.cc7
-rw-r--r--ld/testsuite/ld-elf/dl3.list6
-rw-r--r--ld/testsuite/ld-elf/dl3a.out1
-rw-r--r--ld/testsuite/ld-elf/dl3b.out1
-rw-r--r--ld/testsuite/ld-elf/dl3header.h5
-rw-r--r--ld/testsuite/ld-elf/dl3main.cc25
-rw-r--r--ld/testsuite/ld-elf/shared.exp52
-rw-r--r--ld/testsuite/lib/ld-lib.exp34
20 files changed, 258 insertions, 7 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 62c6fda..7dfff23 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,30 @@
+2006-09-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ld-elf/dl1.c: New file.
+ * ld-elf/dl1.list: Likewise.
+ * ld-elf/dl1.out: Likewise.
+ * ld-elf/dl1main.c: Likewise.
+ * ld-elf/dl2.c: Likewise.
+ * ld-elf/dl2.list: Likewise.
+ * ld-elf/dl2a.out: Likewise.
+ * ld-elf/dl2b.out: Likewise.
+ * ld-elf/dl2main.c: Likewise.
+ * ld-elf/dl2xxx.c: Likewise.
+ * ld-elf/dl2xxx.list: Likewise.
+ * ld-elf/dl3.cc: Likewise.
+ * ld-elf/dl3.list: Likewise.
+ * ld-elf/dl3a.out: Likewise.
+ * ld-elf/dl3b.out: Likewise.
+ * ld-elf/dl3header.h: Likewise.
+ * ld-elf/dl3main.cc: Likewise.
+
+ * ld-elf/shared.exp: Updated.
+
+ * lib/ld-lib.exp (run_ld_link_exec_tests): Take an optional
+ argument for source language. Use CC/CXX for link, depending
+ on source language.
+ (run_cc_link_tests): Likewise.
+
2006-08-29 Alan Modra <amodra@bigpond.net.au>
* ld-elf/loadaddr3a.d: Adjust target test.
diff --git a/ld/testsuite/ld-elf/dl1.c b/ld/testsuite/ld-elf/dl1.c
new file mode 100644
index 0000000..09426f3
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl1.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+extern int bar;
+
+void
+foo (void)
+{
+ if (bar == -20)
+ printf ("OK\n");
+}
diff --git a/ld/testsuite/ld-elf/dl1.list b/ld/testsuite/ld-elf/dl1.list
new file mode 100644
index 0000000..9ffada0
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl1.list
@@ -0,0 +1,6 @@
+{
+ extern "C"
+ {
+ bar;
+ };
+};
diff --git a/ld/testsuite/ld-elf/dl1.out b/ld/testsuite/ld-elf/dl1.out
new file mode 100644
index 0000000..d86bac9
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl1.out
@@ -0,0 +1 @@
+OK
diff --git a/ld/testsuite/ld-elf/dl1main.c b/ld/testsuite/ld-elf/dl1main.c
new file mode 100644
index 0000000..f277bf5
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl1main.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <dlfcn.h>
+
+int bar = -20;
+
+int
+main (void)
+{
+ int ret = 0;
+ void *handle;
+ void (*fcn) (void);
+
+ handle = dlopen("./tmpdir/libdl1.so", RTLD_GLOBAL|RTLD_LAZY);
+ if (!handle)
+ {
+ printf("dlopen libfoo.so: %s\n", dlerror ());
+ return 1;
+ }
+
+ fcn = (void (*)(void)) dlsym(handle, "foo");
+ if (!fcn)
+ {
+ printf("dlsym foo: %s\n", dlerror ());
+ ret += 1;
+ }
+ else
+ {
+ (*fcn) ();
+ }
+
+ dlclose (handle);
+ return ret;
+}
diff --git a/ld/testsuite/ld-elf/dl2.c b/ld/testsuite/ld-elf/dl2.c
new file mode 100644
index 0000000..b5cd927
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl2.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+int foo;
+
+extern void xxx (void);
+
+void
+bar (int x)
+{
+ if (foo == 1)
+ printf ("OK1\n");
+ else if (foo == 0)
+ printf ("OK2\n");
+ foo = -1;
+ xxx ();
+}
diff --git a/ld/testsuite/ld-elf/dl2.list b/ld/testsuite/ld-elf/dl2.list
new file mode 100644
index 0000000..e985dcf
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl2.list
@@ -0,0 +1,3 @@
+{
+ foo;
+};
diff --git a/ld/testsuite/ld-elf/dl2a.out b/ld/testsuite/ld-elf/dl2a.out
new file mode 100644
index 0000000..f3d5b9f
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl2a.out
@@ -0,0 +1,3 @@
+OK1
+DSO
+OK1
diff --git a/ld/testsuite/ld-elf/dl2b.out b/ld/testsuite/ld-elf/dl2b.out
new file mode 100644
index 0000000..f30cead
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl2b.out
@@ -0,0 +1,3 @@
+OK1
+MAIN
+OK1
diff --git a/ld/testsuite/ld-elf/dl2main.c b/ld/testsuite/ld-elf/dl2main.c
new file mode 100644
index 0000000..ddf677f
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl2main.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+extern int foo;
+extern void bar (void);
+
+void
+xxx (void)
+{
+ printf ("MAIN\n");
+}
+
+int
+main (void)
+{
+ foo = 1;
+ bar ();
+ if (foo == -1)
+ printf ("OK1\n");
+ else if (foo == 1)
+ printf ("OK2\n");
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/dl2xxx.c b/ld/testsuite/ld-elf/dl2xxx.c
new file mode 100644
index 0000000..cf3a1d0
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl2xxx.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void
+xxx (void)
+{
+ printf ("DSO\n");
+}
diff --git a/ld/testsuite/ld-elf/dl2xxx.list b/ld/testsuite/ld-elf/dl2xxx.list
new file mode 100644
index 0000000..9388cda
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl2xxx.list
@@ -0,0 +1,3 @@
+{
+ xxx;
+};
diff --git a/ld/testsuite/ld-elf/dl3.cc b/ld/testsuite/ld-elf/dl3.cc
new file mode 100644
index 0000000..558e49f
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl3.cc
@@ -0,0 +1,7 @@
+#include "dl3header.h"
+
+void
+f (void)
+{
+ throw (A (42));
+}
diff --git a/ld/testsuite/ld-elf/dl3.list b/ld/testsuite/ld-elf/dl3.list
new file mode 100644
index 0000000..0b347ea
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl3.list
@@ -0,0 +1,6 @@
+{
+ extern "C++"
+ {
+ typeinfo*;
+ };
+};
diff --git a/ld/testsuite/ld-elf/dl3a.out b/ld/testsuite/ld-elf/dl3a.out
new file mode 100644
index 0000000..d86bac9
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl3a.out
@@ -0,0 +1 @@
+OK
diff --git a/ld/testsuite/ld-elf/dl3b.out b/ld/testsuite/ld-elf/dl3b.out
new file mode 100644
index 0000000..8a15044
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl3b.out
@@ -0,0 +1 @@
+BAD2
diff --git a/ld/testsuite/ld-elf/dl3header.h b/ld/testsuite/ld-elf/dl3header.h
new file mode 100644
index 0000000..66f7d46
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl3header.h
@@ -0,0 +1,5 @@
+struct A
+{
+ int i;
+ A (int i): i(i) {}
+};
diff --git a/ld/testsuite/ld-elf/dl3main.cc b/ld/testsuite/ld-elf/dl3main.cc
new file mode 100644
index 0000000..977f9bb
--- /dev/null
+++ b/ld/testsuite/ld-elf/dl3main.cc
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include "dl3header.h"
+
+extern void f (void);
+
+int
+main (void)
+{
+ try
+ {
+ f();
+ }
+ catch (A a)
+ {
+ if (a.i == 42)
+ printf ("OK\n");
+ else
+ printf ("BAD1\n");
+ }
+ catch (...)
+ {
+ printf ("BAD2\n");
+ }
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 9222358..3090551 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -38,7 +38,7 @@ set build_tests {
{foo.c} {} "libfoo.so"}
{"Build versioned libfoo.so"
"-shared -Wl,--version-script=foo.map" "-fPIC"
- {foo.c} {} "libfoov.so" "-fPIC"}
+ {foo.c} {} "libfoov.so"}
{"Build libbar.so"
"-shared" "-fPIC"
{begin.c end.c} {} "libbar.so"}
@@ -66,6 +66,15 @@ set build_tests {
{"Build protected libbar.so with versioned libfoo.so"
"-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
{endprotected.c} {} "libbarpfoov.so"}
+ {"Build libdl1.so"
+ "-shared" "-fPIC"
+ {dl1.c} {} "libdl1.so"}
+ {"Build libdl2a.so with --dynamic-list=dl2.list"
+ "-shared -Wl,--dynamic-list=dl2.list" "-fPIC"
+ {dl2.c dl2xxx.c} {} "libdl2a.so"}
+ {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
+ "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
+ {dl2.c dl2xxx.c} {} "libdl2b.so"}
}
set run_tests {
@@ -105,8 +114,49 @@ set run_tests {
{"Run hidden libbar.so with versioned libfoo.so"
"tmpdir/libbarhfoov.so tmpdir/libfoov.so" ""
{main.c} "hidden" "hidden.out"}
+ {"Run with dlopen on libdl1.so"
+ "--dynamic-list=dl1.list -ldl" ""
+ {dl1main.c} "dl1" "dl1.out"}
+ {"Run with libdl2a.so"
+ "tmpdir/libdl2a.so" ""
+ {dl2main.c} "dl2a" "dl2a.out"}
+ {"Run with libdl2b.so"
+ "tmpdir/libdl2b.so" ""
+ {dl2main.c} "dl2b" "dl2b.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
+if { [which $CXX] == 0 } {
+ return
+}
+
+set build_cxx_tests {
+ {"Build libdl3a.so with --dynamic-list=dl3.list"
+ "-shared -Wl,--dynamic-list=dl3.list" "-fPIC"
+ {dl3.cc} {} "libdl3a.so" "c++"}
+ {"Build libdl3b.so with -Bsymbolic"
+ "-shared -Wl,-Bsymbolic" "-fPIC"
+ {dl3.cc} {} "libdl3b.so" "c++"}
+ {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
+ "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
+ {dl3.cc} {} "libdl3c.so" "c++"}
+}
+
+set run_cxx_tests {
+ {"Run with libdl3a.so"
+ "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" ""
+ {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
+}
+
+run_cc_link_tests $build_cxx_tests
+run_ld_link_exec_tests [] $run_cxx_tests
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 4b69428..566845f 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -1246,14 +1246,15 @@ if ![string length [info proc prune_warnings]] {
# targets_to_xfail is a list of target triplets to be xfailed.
# ldtests contains test-items with 3 items followed by 1 lists, 2 items
-# and one optional item:
+# and 2 optional items:
# 0:name
# 1:ld options
# 2:assembler options
-# 3:filenames of assembler files
+# 3:filenames of source files
# 4:name of output file
# 5:expected output
# 6:compiler flags (optional)
+# 7:language (optional)
proc run_ld_link_exec_tests { targets_to_xfail ldtests } {
global ld
@@ -1262,6 +1263,7 @@ proc run_ld_link_exec_tests { targets_to_xfail ldtests } {
global subdir
global env
global CC
+ global CXX
global CFLAGS
global errcnt
@@ -1276,6 +1278,7 @@ proc run_ld_link_exec_tests { targets_to_xfail ldtests } {
set binfile tmpdir/[lindex $testitem 4]
set expfile [lindex $testitem 5]
set cflags [lindex $testitem 6]
+ set lang [lindex $testitem 7]
set objfiles {}
set failed 0
@@ -1297,7 +1300,13 @@ proc run_ld_link_exec_tests { targets_to_xfail ldtests } {
ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
# We have to use $CC to build PIE and shared library.
- if { [ string match "-shared" $ld_options ] \
+ if { [ string match "c" $lang ] } {
+ set link_proc ld_simple_link
+ set link_cmd $CC
+ } elseif { [ string match "c++" $lang ] } {
+ set link_proc ld_simple_link
+ set link_cmd $CXX
+ } elseif { [ string match "-shared" $ld_options ] \
|| [ string match "-pie" $ld_options ] } {
set link_proc ld_simple_link
set link_cmd $CC
@@ -1344,8 +1353,13 @@ proc run_ld_link_exec_tests { targets_to_xfail ldtests } {
# List contains test-items with 3 items followed by 2 lists, one item and
# one optional item:
-# 0:name 1:link options 2:compile options
-# 3:filenames of assembler files 4: action and options. 5: name of output file
+# 0:name
+# 1:link options
+# 2:compile options
+# 3:filenames of source files
+# 4:action and options.
+# 5:name of output file
+# 6:language (optional)
#
# Actions:
# objdump: Apply objdump options on result. Compare with regex (last arg).
@@ -1360,6 +1374,7 @@ proc run_cc_link_tests { ldtests } {
global subdir
global env
global CC
+ global CXX
global CFLAGS
foreach testitem $ldtests {
@@ -1369,6 +1384,7 @@ proc run_cc_link_tests { ldtests } {
set src_files [lindex $testitem 3]
set actions [lindex $testitem 4]
set binfile tmpdir/[lindex $testitem 5]
+ set lang [lindex $testitem 6]
set objfiles {}
set is_unresolved 0
set failed 0
@@ -1387,7 +1403,13 @@ proc run_cc_link_tests { ldtests } {
# Clear error and warning counts.
reset_vars
- if ![ld_simple_link $CC $binfile "-L$srcdir/$subdir $ldflags $objfiles"] {
+ if { [ string match "c++" $lang ] } {
+ set cc_cmd $CXX
+ } else {
+ set cc_cmd $CC
+ }
+
+ if ![ld_simple_link $cc_cmd $binfile "-L$srcdir/$subdir $ldflags $objfiles"] {
fail $testname
} else {
set failed 0