From: H.J. Lu Date: Mon, 5 Jun 2000 20:43:18 +0000 (+0000) Subject: 2000-06-05 H.J. Lu (hjl@gnu.org) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7cda33a15efa285ef24ad6bbcc6c4dfc4d73a0cd;p=binutils-gdb.git 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. --- diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 281fca4ea69..a3beb9a02fd 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 9f1778d0966..e94a178e14b 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 746200ee14a..3c45e511e1d 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 97bb2200e73..eef5c01ba04 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 c4bdcc75969..5a140a8c3e0 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 013a4e0994f..6ed30bc52e1 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 417ccbaf7c6..11185d825fd 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.