aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-elf
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2006-09-07 17:16:34 +0000
committerH.J. Lu <hjl.tools@gmail.com>2006-09-07 17:16:34 +0000
commit55255daec3c2b3f212acfdfe9cefe9fd2899253f (patch)
tree1c54880b4a75b647aa760b69aa0c746024b269c3 /ld/testsuite/ld-elf
parent7c94efc52259df93dbe9aa3e4dcb1334bd460aef (diff)
downloadgdb-55255daec3c2b3f212acfdfe9cefe9fd2899253f.zip
gdb-55255daec3c2b3f212acfdfe9cefe9fd2899253f.tar.gz
gdb-55255daec3c2b3f212acfdfe9cefe9fd2899253f.tar.bz2
bfd/
2006-09-07 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (elf_link_hash_entry): Add a dynamic field. (bfd_elf_link_mark_dynamic_symbol): New. (SYMBOLIC_BIND): New. * elf32-i386.c (elf_i386_check_relocs): Replace info->symbolic with SYMBOLIC_BIND (info, h). (elf_i386_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise. (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_check_relocs): Likewise. * elflink.c (bfd_elf_link_mark_dynamic_symbol): New. (bfd_elf_record_link_assignment): Call bfd_elf_link_mark_dynamic_symbol on new entry. (_bfd_elf_merge_symbol): Likewise. (_bfd_elf_export_symbol): Return if the symbol isn't exported. (_bfd_elf_fix_symbol_flags): Replace info->symbolic with SYMBOLIC_BIND (info, h). (_bfd_elf_dynamic_symbol_p): Likewise. (_bfd_elf_symbol_refs_local_p): Likewise. (bfd_elf_size_dynamic_sections): Updated. include/ 2006-09-07 H.J. Lu <hongjiu.lu@intel.com> * bfdlink.h (bfd_elf_dynamic_list): New. (bfd_link_info): Add a dynamic field. ld/ 2006-09-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CXX): Set to g++. (CXX_FOR_TARGET): Likewise. * Makefile.in: Regenerated. * NEWS: Mention --dynamic-list. * ld.texinfo: Document --dynamic-list. * ldgram.y: Support dynamic list. * ldlang.c (lang_process): Call lang_finalize_version_expr_head on link_info.dynamic if needed. (lang_append_dynamic_list): New. (lang_append_dynamic_list_cpp_typeinfo): New. * ldlang.h (lang_append_dynamic_list): Likewise. * ldlang.h (lang_append_dynamic_list_cpp_typeinfo): Likewise. * ldlex.h (input_enum): Add input_dynamic_list. * ldlex.l: Handle it. * ldmain.c (main): Initialize link_info.dynamic. * lexsup.c (option_values): Add OPTION_DYNAMIC_LIST and OPTION_DYNAMIC_LIST_CPP_TYPEINFO. (ld_options): Add entries for OPTION_DYNAMIC_LIST and OPTION_DYNAMIC_LIST_CPP_TYPEINFO. (parse_args): Handle OPTION_DYNAMIC_LIST and OPTION_DYNAMIC_LIST_CPP_TYPEINFO. ld/testsuite/ 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.
Diffstat (limited to 'ld/testsuite/ld-elf')
-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
18 files changed, 203 insertions, 1 deletions
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