aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog15
-rw-r--r--ld/testsuite/ld-elfvsb/elfvsb.dat3
-rw-r--r--ld/testsuite/ld-elfvsb/elfvsb.exp45
-rw-r--r--ld/testsuite/ld-elfvsb/main.c50
-rw-r--r--ld/testsuite/ld-elfvsb/sh1.c111
-rw-r--r--ld/testsuite/ld-elfvsb/sh2.c10
-rw-r--r--ld/testsuite/lib/ld-lib.exp7
7 files changed, 230 insertions, 11 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 281fca4..a3beb9a 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,18 @@
+2000-06-05 H.J. Lu (hjl@gnu.org)
+
+ * lib/ld-lib.exp (default_ld_link): Redirect the linker output
+ to link_output and make it global.
+
+ * ld-elfvsb/elfvsb.exp (visibility_test): Add "hidden_undef",
+ "hidden_undef_def", "hidden_weak", "protected_undef",
+ "protected_undef_def" and "protected_weak".
+ (visibility_run): Likewise.
+ * ld-elfvsb/main.c: Likewise.
+ * ld-elfvsb/sh1.c: Likewise.
+ * ld-elfvsb/sh2.c: Likewise.
+
+ * ld-elfvsb/elfvsb.dat: Updated.
+
2000-05-21 H.J. Lu (hjl@gnu.org)
* ld-elfvsb/main.c (main_visibility_check): Fix the protected
diff --git a/ld/testsuite/ld-elfvsb/elfvsb.dat b/ld/testsuite/ld-elfvsb/elfvsb.dat
index 9f1778d..e94a178 100644
--- a/ld/testsuite/ld-elfvsb/elfvsb.dat
+++ b/ld/testsuite/ld-elfvsb/elfvsb.dat
@@ -17,3 +17,6 @@ shlib_check () == 1
visibility_check () == 1
visibility_checkfunptr () == 1
main_visibility_check () == 1
+visibility_checkvar () == 1
+visibility_checkvarptr () == 1
+main_visibility_checkvar () == 1
diff --git a/ld/testsuite/ld-elfvsb/elfvsb.exp b/ld/testsuite/ld-elfvsb/elfvsb.exp
index 746200e..3c45e51 100644
--- a/ld/testsuite/ld-elfvsb/elfvsb.exp
+++ b/ld/testsuite/ld-elfvsb/elfvsb.exp
@@ -93,7 +93,17 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
}
if {![ld_simple_link $ld $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
- fail "$testname"
+ if { [ string match $visibility "hidden_undef" ]
+ && [regexp ".*/sh1.c.*: undefined reference to \`visibility\'" $link_output]
+ && [regexp ".*/sh1.c.*: undefined reference to \`visibility_var\'" $link_output] } {
+ pass "$testname"
+ } else { if { [ string match $visibility "protected_undef" ]
+ && [regexp ".*/sh1.c.*: undefined reference to \`visibility\'" $link_output]
+ && [regexp ".*/sh1.c.*: undefined reference to \`visibility_var\'" $link_output] } {
+ pass "$testname"
+ } else {
+ fail "$testname"
+ }}
return
}
@@ -107,15 +117,22 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
}
if ![ld_link $ld $tmpdir/$progname "-rpath $rpath $tmpdir/$main $tmpdir/$progname.so"] {
if { [ string match $visibility "hidden" ]
- && [string match "*/main.c*: undefined reference to \`visibility\'" $link_output] } {
+ && [regexp ".*/main.c.*: undefined reference to \`visibility\'" $link_output]
+ && [regexp ".*/main.c.*: undefined reference to \`visibility_var\'" $link_output] } {
+ 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_var\'" $link_output] } {
pass "$testname"
} else {
fail "$testname"
- }
+ }}
return
}
- if [ string match $visibility "hidden" ] {
+ if { [ string match $visibility "hidden" ]
+ || [ string match $visibility "hidden_undef" ]
+ || [ string match $visibility "protected_undef" ] } {
fail "$testname"
}
@@ -159,11 +176,23 @@ proc visibility_run {visibility} {
set VSBCFLAG "-DHIDDEN_TEST"
} else { if [ string match $visibility "hidden_normal" ] {
set VSBCFLAG "-DHIDDEN_NORMAL_TEST"
+ } else { if [ string match $visibility "hidden_undef" ] {
+ set VSBCFLAG "-DHIDDEN_UNDEF_TEST"
+ } else { if [ string match $visibility "hidden_undef_def" ] {
+ set VSBCFLAG "-DHIDDEN_UNDEF_TEST -DDSO_DEFINE_TEST"
+ } else { if [ string match $visibility "hidden_weak" ] {
+ set VSBCFLAG "-DHIDDEN_WEAK_TEST"
} else { if [ string match $visibility "protected" ] {
set VSBCFLAG "-DPROTECTED_TEST"
+ } else { if [ string match $visibility "protected_undef" ] {
+ set VSBCFLAG "-DPROTECTED_UNDEF_TEST"
+ } else { if [ string match $visibility "protected_undef_def" ] {
+ set VSBCFLAG "-DPROTECTED_UNDEF_TEST -DDSO_DEFINE_TEST"
+ } else { if [ string match $visibility "protected_weak" ] {
+ set VSBCFLAG "-DPROTECTED_WEAK_TEST"
} else {
set VSBCFLAG ""
- }}}
+ }}}}}}}}}
# Compile the main program.
if ![ld_compile "$CC $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
@@ -289,7 +318,13 @@ verbose "Using $picflag to compile PIC code"
visibility_run hidden
visibility_run hidden_normal
+visibility_run hidden_undef
+visibility_run hidden_undef_def
+visibility_run hidden_weak
visibility_run protected
+visibility_run protected_undef
+visibility_run protected_undef_def
+visibility_run protected_weak
visibility_run normal
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
diff --git a/ld/testsuite/ld-elfvsb/main.c b/ld/testsuite/ld-elfvsb/main.c
index 97bb220..eef5c01 100644
--- a/ld/testsuite/ld-elfvsb/main.c
+++ b/ld/testsuite/ld-elfvsb/main.c
@@ -18,10 +18,28 @@ extern int (*shlib_getfunptr1 ()) ();
extern int (*shlib_getfunptr2 ()) ();
extern int shlib_check ();
extern int shlib_shlibcall2 ();
-extern int visibility ();
extern int visibility_check ();
extern int visibility_checkfunptr ();
extern void *visibility_funptr ();
+extern int visibility_checkvar ();
+extern int visibility_checkvarptr ();
+extern int visibility_varval ();
+extern void *visibility_varptr ();
+
+#ifdef HIDDEN_WEAK_TEST
+#define HIDDEN_UNDEF_TEST
+#define WEAK_TEST
+#endif
+
+#ifdef PROTECTED_WEAK_TEST
+#define PROTECTED_UNDEF_TEST
+#define WEAK_TEST
+#endif
+
+#ifndef WEAK_TEST
+extern int visibility ();
+extern int visibility_var;
+#endif
#if !defined (HIDDEN_TEST) && defined (PROTECTED_TEST)
int
@@ -35,11 +53,36 @@ main_visibility_check ()
{
return visibility_funptr () != visibility;
}
+
+int visibility_var = 1;
+
+static int
+main_visibility_checkvar ()
+{
+ return visibility_varval () != visibility_var
+ && visibility_varptr () != &visibility_var;
+}
#else
static int
main_visibility_check ()
{
+#ifdef WEAK_TEST
+ return visibility_funptr () == NULL;
+#else
return visibility_funptr () == visibility;
+#endif
+}
+
+static int
+main_visibility_checkvar ()
+{
+#ifdef WEAK_TEST
+ return visibility_varval () == 0
+ && visibility_varptr () == NULL;
+#else
+ return visibility_varval () == visibility_var
+ && visibility_varptr () == &visibility_var;
+#endif
}
#endif
@@ -106,5 +149,10 @@ main ()
printf ("visibility_checkfunptr () == %d\n",
visibility_checkfunptr ());
printf ("main_visibility_check () == %d\n", main_visibility_check ());
+ printf ("visibility_checkvar () == %d\n", visibility_checkvar ());
+ printf ("visibility_checkvarptr () == %d\n",
+ visibility_checkvarptr ());
+ printf ("main_visibility_checkvar () == %d\n",
+ main_visibility_checkvar ());
return 0;
}
diff --git a/ld/testsuite/ld-elfvsb/sh1.c b/ld/testsuite/ld-elfvsb/sh1.c
index c4bdcc7..5a140a8 100644
--- a/ld/testsuite/ld-elfvsb/sh1.c
+++ b/ld/testsuite/ld-elfvsb/sh1.c
@@ -1,3 +1,7 @@
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
/* This is part of the shared library ld test. This file becomes part
of a shared library. */
@@ -165,11 +169,25 @@ shlib_check ()
return 1;
}
+#ifdef HIDDEN_WEAK_TEST
+#define HIDDEN_UNDEF_TEST
+#define WEAK_TEST
+#endif
+
+#ifdef PROTECTED_WEAK_TEST
+#define PROTECTED_UNDEF_TEST
+#define WEAK_TEST
+#endif
+
+#if defined (HIDDEN_UNDEF_TEST) || defined (PROTECTED_UNDEF_TEST)
+extern int visibility ();
+#else
int
visibility ()
{
return 2;
}
+#endif
#ifdef HIDDEN_NORMAL_TEST
asm (".hidden visibility_normal");
@@ -184,32 +202,121 @@ visibility_normal ()
int
visibility_checkfunptr ()
{
+#ifdef WEAK_TEST
+ return 1;
+#else
#ifdef HIDDEN_NORMAL_TEST
int (*v) () = visibility_normal;
#else
int (*v) () = visibility;
#endif
return (*v) () == 2;
+#endif
}
int
visibility_check ()
{
+#ifdef WEAK_TEST
+ if (&visibility)
+ return visibility () == 1;
+ else
+ return 1;
+#else
#ifdef HIDDEN_NORMAL_TEST
return visibility_normal () == 2;
#else
return visibility () == 2;
#endif
+#endif
}
void *
visibility_funptr ()
{
- return visibility;
+#ifdef WEAK_TEST
+ if (&visibility == NULL)
+ return NULL;
+ else
+#endif
+ return visibility;
}
-#ifdef HIDDEN_TEST
+#if defined (HIDDEN_UNDEF_TEST) || defined (PROTECTED_UNDEF_TEST)
+extern int visibility_var;
+#else
+int visibility_var = 2;
+#endif
+
+#ifdef HIDDEN_NORMAL_TEST
+asm (".hidden visibility_var_normal");
+
+int visibility_var_normal = 2;
+#endif
+
+int
+visibility_checkvarptr ()
+{
+#ifdef WEAK_TEST
+ if (&visibility_var)
+ return visibility_var == 1;
+ else
+ return 1;
+#else
+#ifdef HIDDEN_NORMAL_TEST
+ int *v = &visibility_var_normal;
+#else
+ int *v = &visibility_var;
+#endif
+ return *v == 2;
+#endif
+}
+
+int
+visibility_checkvar ()
+{
+#ifdef WEAK_TEST
+ return 1;
+#else
+#ifdef HIDDEN_NORMAL_TEST
+ return visibility_var_normal == 2;
+#else
+ return visibility_var == 2;
+#endif
+#endif
+}
+
+void *
+visibility_varptr ()
+{
+#ifdef WEAK_TEST
+ if (&visibility_var == NULL)
+ return NULL;
+ else
+#endif
+ return &visibility_var;
+}
+
+int
+visibility_varval ()
+{
+#ifdef WEAK_TEST
+ if (&visibility_var == NULL)
+ return 0;
+ else
+#endif
+ return visibility_var;
+}
+
+#if defined (HIDDEN_TEST) || defined (HIDDEN_UNDEF_TEST)
asm (".hidden visibility");
+asm (".hidden visibility_var");
#else
asm (".protected visibility");
+asm (".protected visibility_var");
+#endif
+
+#ifdef WEAK_TEST
+asm (".weak visibility");
+asm (".weak visibility_var");
#endif
diff --git a/ld/testsuite/ld-elfvsb/sh2.c b/ld/testsuite/ld-elfvsb/sh2.c
index 013a4e0..6ed30bc 100644
--- a/ld/testsuite/ld-elfvsb/sh2.c
+++ b/ld/testsuite/ld-elfvsb/sh2.c
@@ -12,3 +12,13 @@ shlib_shlibcalled ()
{
return 5;
}
+
+#ifdef DSO_DEFINE_TEST
+int
+visibility ()
+{
+ return 2;
+}
+
+int visibility_var = 2;
+#endif
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 417ccba..11185d8 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -115,7 +115,8 @@ proc default_ld_link { ld target objects } {
#
proc default_ld_simple_link { ld target objects } {
global host_triplet
-
+ global link_output
+
if { [which $ld] == 0 } then {
perror "$ld does not exist"
return 0
@@ -125,8 +126,8 @@ proc default_ld_simple_link { ld target objects } {
verbose -log "$ld $flags -o $target $objects"
- catch "exec $ld $flags -o $target $objects" exec_output
- set exec_output [prune_warnings $exec_output]
+ catch "exec $ld $flags -o $target $objects" link_output
+ set exec_output [prune_warnings $link_output]
# We don't care if we get a warning about a non-existent start
# symbol, since the default linker script might use ENTRY.