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.
This commit is contained in:
H.J. Lu
2000-06-05 20:43:18 +00:00
parent 422ea4b878
commit 7cda33a15e
7 changed files with 230 additions and 11 deletions

View File

@ -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) 2000-05-21 H.J. Lu (hjl@gnu.org)
* ld-elfvsb/main.c (main_visibility_check): Fix the protected * ld-elfvsb/main.c (main_visibility_check): Fix the protected

View File

@ -17,3 +17,6 @@ shlib_check () == 1
visibility_check () == 1 visibility_check () == 1
visibility_checkfunptr () == 1 visibility_checkfunptr () == 1
main_visibility_check () == 1 main_visibility_check () == 1
visibility_checkvar () == 1
visibility_checkvarptr () == 1
main_visibility_checkvar () == 1

View File

@ -93,7 +93,17 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
set shared "-bM:SRE -bE:$tmpdir/xcoff.exp" set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
} }
if {![ld_simple_link $ld $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} { 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 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 ![ld_link $ld $tmpdir/$progname "-rpath $rpath $tmpdir/$main $tmpdir/$progname.so"] {
if { [ string match $visibility "hidden" ] 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" pass "$testname"
} else { } else {
fail "$testname" fail "$testname"
} }}
return return
} }
if [ string match $visibility "hidden" ] { if { [ string match $visibility "hidden" ]
|| [ string match $visibility "hidden_undef" ]
|| [ string match $visibility "protected_undef" ] } {
fail "$testname" fail "$testname"
} }
@ -159,11 +176,23 @@ proc visibility_run {visibility} {
set VSBCFLAG "-DHIDDEN_TEST" set VSBCFLAG "-DHIDDEN_TEST"
} else { if [ string match $visibility "hidden_normal" ] { } else { if [ string match $visibility "hidden_normal" ] {
set VSBCFLAG "-DHIDDEN_NORMAL_TEST" 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" ] { } else { if [ string match $visibility "protected" ] {
set VSBCFLAG "-DPROTECTED_TEST" 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 { } else {
set VSBCFLAG "" set VSBCFLAG ""
}}} }}}}}}}}}
# Compile the main program. # Compile the main program.
if ![ld_compile "$CC $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] { 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
visibility_run hidden_normal visibility_run hidden_normal
visibility_run hidden_undef
visibility_run hidden_undef_def
visibility_run hidden_weak
visibility_run protected visibility_run protected
visibility_run protected_undef
visibility_run protected_undef_def
visibility_run protected_weak
visibility_run normal visibility_run normal
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {

View File

@ -18,10 +18,28 @@ extern int (*shlib_getfunptr1 ()) ();
extern int (*shlib_getfunptr2 ()) (); extern int (*shlib_getfunptr2 ()) ();
extern int shlib_check (); extern int shlib_check ();
extern int shlib_shlibcall2 (); extern int shlib_shlibcall2 ();
extern int visibility ();
extern int visibility_check (); extern int visibility_check ();
extern int visibility_checkfunptr (); extern int visibility_checkfunptr ();
extern void *visibility_funptr (); 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) #if !defined (HIDDEN_TEST) && defined (PROTECTED_TEST)
int int
@ -35,11 +53,36 @@ main_visibility_check ()
{ {
return visibility_funptr () != visibility; return visibility_funptr () != visibility;
} }
int visibility_var = 1;
static int
main_visibility_checkvar ()
{
return visibility_varval () != visibility_var
&& visibility_varptr () != &visibility_var;
}
#else #else
static int static int
main_visibility_check () main_visibility_check ()
{ {
#ifdef WEAK_TEST
return visibility_funptr () == NULL;
#else
return visibility_funptr () == visibility; 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 #endif
@ -106,5 +149,10 @@ main ()
printf ("visibility_checkfunptr () == %d\n", printf ("visibility_checkfunptr () == %d\n",
visibility_checkfunptr ()); visibility_checkfunptr ());
printf ("main_visibility_check () == %d\n", main_visibility_check ()); 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; return 0;
} }

View File

@ -1,3 +1,7 @@
#ifndef NULL
#define NULL ((void *) 0)
#endif
/* This is part of the shared library ld test. This file becomes part /* This is part of the shared library ld test. This file becomes part
of a shared library. */ of a shared library. */
@ -165,11 +169,25 @@ shlib_check ()
return 1; 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 int
visibility () visibility ()
{ {
return 2; return 2;
} }
#endif
#ifdef HIDDEN_NORMAL_TEST #ifdef HIDDEN_NORMAL_TEST
asm (".hidden visibility_normal"); asm (".hidden visibility_normal");
@ -184,32 +202,121 @@ visibility_normal ()
int int
visibility_checkfunptr () visibility_checkfunptr ()
{ {
#ifdef WEAK_TEST
return 1;
#else
#ifdef HIDDEN_NORMAL_TEST #ifdef HIDDEN_NORMAL_TEST
int (*v) () = visibility_normal; int (*v) () = visibility_normal;
#else #else
int (*v) () = visibility; int (*v) () = visibility;
#endif #endif
return (*v) () == 2; return (*v) () == 2;
#endif
} }
int int
visibility_check () visibility_check ()
{ {
#ifdef WEAK_TEST
if (&visibility)
return visibility () == 1;
else
return 1;
#else
#ifdef HIDDEN_NORMAL_TEST #ifdef HIDDEN_NORMAL_TEST
return visibility_normal () == 2; return visibility_normal () == 2;
#else #else
return visibility () == 2; return visibility () == 2;
#endif #endif
#endif
} }
void * void *
visibility_funptr () 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");
asm (".hidden visibility_var");
#else #else
asm (".protected visibility"); asm (".protected visibility");
asm (".protected visibility_var");
#endif
#ifdef WEAK_TEST
asm (".weak visibility");
asm (".weak visibility_var");
#endif #endif

View File

@ -12,3 +12,13 @@ shlib_shlibcalled ()
{ {
return 5; return 5;
} }
#ifdef DSO_DEFINE_TEST
int
visibility ()
{
return 2;
}
int visibility_var = 2;
#endif

View File

@ -115,7 +115,8 @@ proc default_ld_link { ld target objects } {
# #
proc default_ld_simple_link { ld target objects } { proc default_ld_simple_link { ld target objects } {
global host_triplet global host_triplet
global link_output
if { [which $ld] == 0 } then { if { [which $ld] == 0 } then {
perror "$ld does not exist" perror "$ld does not exist"
return 0 return 0
@ -125,8 +126,8 @@ proc default_ld_simple_link { ld target objects } {
verbose -log "$ld $flags -o $target $objects" verbose -log "$ld $flags -o $target $objects"
catch "exec $ld $flags -o $target $objects" exec_output catch "exec $ld $flags -o $target $objects" link_output
set exec_output [prune_warnings $exec_output] set exec_output [prune_warnings $link_output]
# We don't care if we get a warning about a non-existent start # We don't care if we get a warning about a non-existent start
# symbol, since the default linker script might use ENTRY. # symbol, since the default linker script might use ENTRY.