summaryrefslogtreecommitdiffstats
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2003-04-28 03:31:36 +0000
committerH.J. Lu <hjl.tools@gmail.com>2003-04-28 03:31:36 +0000
commit1b1fe8feb35ab988cdaf8481fc52ebdbf2db3d93 (patch)
treef9cd4673bf8f9417762ecead3785bcb37244a8a4 /ld
parente4c4d240a370f0afc8a29b18f8e07affff9c4177 (diff)
downloadppe42-binutils-1b1fe8feb35ab988cdaf8481fc52ebdbf2db3d93.tar.gz
ppe42-binutils-1b1fe8feb35ab988cdaf8481fc52ebdbf2db3d93.zip
bfd/
2003-04-27 H.J. Lu <hjl@gnu.org> * elf-bfd.h (ELF_LINK_DYNAMIC_DEF): New. (ELF_LINK_DYNAMIC_WEAK): New. * elflink.h (elf_merge_symbol): Add one argument to indicate if a symbol should be skipped. Ignore definitions in dynamic objects for symbols with non-default visibility. (elf_add_default_symbol): Adjusted. (elf_link_add_object_symbols): Check if a symbol should be skipped. Don't merge the visibility field with the one from a dynamic object. (elf_link_check_versioned_symbol): Use undef_bfd. (elf_link_output_extsym): Warn if a forced local symbol is referenced from dynamic objects. Make non-weak undefined symbol with non-default visibility a fatal error. ld/testsuite/ 2003-04-27 H.J. Lu <hjl@gnu.org> * ld-elfvsb/elfvsb.dat: Updated. * ld-elfvsb/elfvsb.exp: Likewise. * ld-elfvsb/main.c: Likewise. * ld-elfvsb/sh1.c: Likewise. * ld-elfvsb/sh2.c: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog8
-rw-r--r--ld/testsuite/ld-elfvsb/elfvsb.dat4
-rw-r--r--ld/testsuite/ld-elfvsb/elfvsb.exp2
-rw-r--r--ld/testsuite/ld-elfvsb/main.c99
-rw-r--r--ld/testsuite/ld-elfvsb/sh1.c51
-rw-r--r--ld/testsuite/ld-elfvsb/sh2.c22
6 files changed, 185 insertions, 1 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index a0ae7fdf8b..8334e587d8 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2003-04-27 H.J. Lu <hjl@gnu.org>
+
+ * ld-elfvsb/elfvsb.dat: Updated.
+ * ld-elfvsb/elfvsb.exp: Likewise.
+ * ld-elfvsb/main.c: Likewise.
+ * ld-elfvsb/sh1.c: Likewise.
+ * ld-elfvsb/sh2.c: Likewise.
+
2003-04-26 Stephane Carrez <stcarrez@nerim.fr>
* ld-m68hc11/bug-3331.d: New test.
diff --git a/ld/testsuite/ld-elfvsb/elfvsb.dat b/ld/testsuite/ld-elfvsb/elfvsb.dat
index e94a178e14..bad3b1ec14 100644
--- a/ld/testsuite/ld-elfvsb/elfvsb.dat
+++ b/ld/testsuite/ld-elfvsb/elfvsb.dat
@@ -20,3 +20,7 @@ main_visibility_check () == 1
visibility_checkvar () == 1
visibility_checkvarptr () == 1
main_visibility_checkvar () == 1
+main_visibility_checkcom () == 1
+shlib_visibility_checkcom () == 1
+main_visibility_checkweak () == 1
+shlib_visibility_checkweak () == 1
diff --git a/ld/testsuite/ld-elfvsb/elfvsb.exp b/ld/testsuite/ld-elfvsb/elfvsb.exp
index c4f82f45c0..220e28251a 100644
--- a/ld/testsuite/ld-elfvsb/elfvsb.exp
+++ b/ld/testsuite/ld-elfvsb/elfvsb.exp
@@ -144,6 +144,8 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
pass "$testname"
} else { if { [ string match $visibility "hidden_undef_def" ]
&& [regexp ".*/main.c.*: undefined reference to \`visibility\'" $link_output]
+ && [regexp ".*/main.c.*: undefined reference to \`visibility_def\'" $link_output]
+ && [regexp ".*/main.c.*: undefined reference to \`visibility_func\'" $link_output]
&& [regexp ".*/main.c.*: undefined reference to \`visibility_var\'" $link_output] } {
pass "$testname"
} else {
diff --git a/ld/testsuite/ld-elfvsb/main.c b/ld/testsuite/ld-elfvsb/main.c
index 26542b8a1f..6ce97bf4b2 100644
--- a/ld/testsuite/ld-elfvsb/main.c
+++ b/ld/testsuite/ld-elfvsb/main.c
@@ -42,6 +42,18 @@ extern int visibility_checkvar ();
extern int visibility_checkvarptr ();
extern int visibility_varval ();
extern void *visibility_varptr ();
+extern int shlib_visibility_checkcom ();
+extern int shlib_visibility_checkweak ();
+
+int shlib_visibility_com = 1;
+
+int shlib_visibility_var_weak = 1;
+
+int
+shlib_visibility_func_weak ()
+{
+ return 1;
+}
#ifdef HIDDEN_WEAK_TEST
#define WEAK_TEST
@@ -81,6 +93,23 @@ main_visibility_checkvar ()
return visibility_varval () != visibility_var
&& visibility_varptr () != &visibility_var;
}
+
+#ifndef PROTECTED_UNDEF_TEST
+int shared_data = 1;
+asm (".protected shared_data");
+
+int
+shared_func ()
+{
+ return 1;
+}
+
+asm (".protected shared_func");
+
+extern int * shared_data_p ();
+typedef int (*func) ();
+extern func shared_func_p ();
+#endif
#else
static int
main_visibility_check ()
@@ -121,10 +150,57 @@ shlib_overriddencall2 ()
return 8;
}
+#ifdef HIDDEN_NORMAL_TEST
+int visibility_com;
+asm (".hidden visibility_com");
+
+int
+main_visibility_checkcom ()
+{
+ return visibility_com == 0;
+}
+
+int
+main_visibility_checkweak ()
+{
+ return 1;
+}
+#elif defined (HIDDEN_UNDEF_TEST)
+extern int visibility_def;
+asm (".hidden visibility_def");
+extern int visibility_func ();
+asm (".hidden visibility_func");
+
+int
+main_visibility_checkcom ()
+{
+ return &visibility_def != NULL;
+}
+
+int
+main_visibility_checkweak ()
+{
+ return &visibility_func != NULL;
+}
+#else
+int
+main_visibility_checkcom ()
+{
+ return 1;
+}
+
+int
+main_visibility_checkweak ()
+{
+ return 1;
+}
+#endif
+
int
main ()
{
int (*p) ();
+ int ret = 0;
printf ("mainvar == %d\n", mainvar);
printf ("overriddenvar == %d\n", overriddenvar);
@@ -173,6 +249,27 @@ main ()
visibility_checkvarptr ());
printf ("main_visibility_checkvar () == %d\n",
main_visibility_checkvar ());
- return 0;
+ printf ("main_visibility_checkcom () == %d\n",
+ main_visibility_checkcom ());
+ printf ("shlib_visibility_checkcom () == %d\n",
+ shlib_visibility_checkcom ());
+ printf ("main_visibility_checkweak () == %d\n",
+ main_visibility_checkweak ());
+ printf ("shlib_visibility_checkweak () == %d\n",
+ shlib_visibility_checkweak ());
+
+#if !defined (PROTECTED_UNDEF_TEST) && defined (PROTECTED_TEST)
+ if (&shared_data != shared_data_p ())
+ ret = 1;
+ p = shared_func_p ();
+ if (shared_func != p)
+ ret = 1;
+ if (shared_data != *shared_data_p ())
+ ret = 1;
+ if (shared_func () != (*p) () )
+ ret = 1;
+#endif
+
+ return ret;
}
#endif
diff --git a/ld/testsuite/ld-elfvsb/sh1.c b/ld/testsuite/ld-elfvsb/sh1.c
index 41bc4934d2..2b9b9eeb52 100644
--- a/ld/testsuite/ld-elfvsb/sh1.c
+++ b/ld/testsuite/ld-elfvsb/sh1.c
@@ -323,3 +323,54 @@ asm (".protected visibility");
asm (".protected visibility_var");
#endif
#endif
+
+#ifdef HIDDEN_NORMAL_TEST
+int shlib_visibility_com;
+asm (".hidden shlib_visibility_com");
+
+int
+shlib_visibility_checkcom ()
+{
+ return shlib_visibility_com == 0;
+}
+
+int
+shlib_visibility_checkweak ()
+{
+ return 1;
+}
+#else
+int
+shlib_visibility_checkcom ()
+{
+ return 1;
+}
+
+int
+shlib_visibility_checkweak ()
+{
+ return 1;
+}
+#endif
+
+#ifdef PROTECTED_TEST
+int shared_data = 100;
+
+int *
+shared_data_p ()
+{
+ return &shared_data;
+}
+
+int
+shared_func ()
+{
+ return 100;
+}
+
+void *
+shared_func_p ()
+{
+ return shared_func;
+}
+#endif
diff --git a/ld/testsuite/ld-elfvsb/sh2.c b/ld/testsuite/ld-elfvsb/sh2.c
index 6ed30bc52e..ef6b2f16f6 100644
--- a/ld/testsuite/ld-elfvsb/sh2.c
+++ b/ld/testsuite/ld-elfvsb/sh2.c
@@ -5,6 +5,10 @@
the shared library. */
int shlibvar2 = 4;
+/* This variable is defined here, and shouldn't be used to resolve a
+ reference with non-default visibility in another shared library. */
+int visibility_com = 2;
+
/* This function is called by another file in the shared library. */
int
@@ -21,4 +25,22 @@ visibility ()
}
int visibility_var = 2;
+
+int visibility_def = 2;
+
+int
+visibility_func ()
+{
+ return 2;
+}
+#endif
+
+#ifdef HIDDEN_WEAK_TEST
+int visibility_var_weak = 2;
+
+int
+visibility_func_weak ()
+{
+ return 2;
+}
#endif
OpenPOWER on IntegriCloud