diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2000-05-13 16:54:32 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2000-05-13 16:54:32 +0000 |
commit | 6fc49d288b851bc5732d85155af3fac92e7906e3 (patch) | |
tree | a0350d23a2d1362f7500ff2ef9b72ac5c8467dcf /ld/testsuite/ld-elfvsb/main.c | |
parent | 558b0a60a80a669201f7ffa51dd553ce607a7ad6 (diff) | |
download | gdb-6fc49d288b851bc5732d85155af3fac92e7906e3.zip gdb-6fc49d288b851bc5732d85155af3fac92e7906e3.tar.gz gdb-6fc49d288b851bc5732d85155af3fac92e7906e3.tar.bz2 |
2000-05-13 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/elf-offset.ld: New. ELF visibility fearture
tests.
* ld-elfvsb/elfvsb.dat: Likewise.
* ld-elfvsb/elfvsb.exp: Likewise.
* ld-elfvsb/main.c: Likewise.
* ld-elfvsb/sh1.c: Likewise.
* ld-elfvsb/sh2.c: Likewise.
Diffstat (limited to 'ld/testsuite/ld-elfvsb/main.c')
-rw-r--r-- | ld/testsuite/ld-elfvsb/main.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elfvsb/main.c b/ld/testsuite/ld-elfvsb/main.c new file mode 100644 index 0000000..4a41315 --- /dev/null +++ b/ld/testsuite/ld-elfvsb/main.c @@ -0,0 +1,104 @@ +/* This is the main program for the shared library test. */ + +#include <stdio.h> + +int mainvar = 1; +int overriddenvar = 2; +extern int shlibvar1; + +extern int shlib_mainvar (); +extern int shlib_overriddenvar (); +extern int shlib_shlibvar1 (); +extern int shlib_shlibvar2 (); +extern int shlib_shlibcall (); +extern int shlib_maincall (); +extern int shlib_checkfunptr1 (); +extern int shlib_checkfunptr2 (); +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 (); + +#if !defined (HIDDEN_TEST) && defined (PROTECTED_TEST) +int +visibility () +{ + return 1; +} +#endif + +static int +main_visibility_check () +{ + return visibility_funptr () == visibility; +} + +/* This function is called by the shared library. */ + +int +main_called () +{ + return 6; +} + +/* This function overrides a function in the shared library. */ + +int +shlib_overriddencall2 () +{ + return 8; +} + +int +main () +{ + int (*p) (); + + printf ("mainvar == %d\n", mainvar); + printf ("overriddenvar == %d\n", overriddenvar); + printf ("shlibvar1 == %d\n", shlibvar1); +#ifndef XCOFF_TEST + printf ("shlib_mainvar () == %d\n", shlib_mainvar ()); + printf ("shlib_overriddenvar () == %d\n", shlib_overriddenvar ()); +#endif + printf ("shlib_shlibvar1 () == %d\n", shlib_shlibvar1 ()); + printf ("shlib_shlibvar2 () == %d\n", shlib_shlibvar2 ()); + printf ("shlib_shlibcall () == %d\n", shlib_shlibcall ()); +#ifndef XCOFF_TEST + printf ("shlib_shlibcall2 () == %d\n", shlib_shlibcall2 ()); + printf ("shlib_maincall () == %d\n", shlib_maincall ()); +#endif + printf ("main_called () == %d\n", main_called ()); + printf ("shlib_checkfunptr1 (shlib_shlibvar1) == %d\n", + shlib_checkfunptr1 (shlib_shlibvar1)); +#ifndef XCOFF_TEST + printf ("shlib_checkfunptr2 (main_called) == %d\n", + shlib_checkfunptr2 (main_called)); +#endif + p = shlib_getfunptr1 (); + printf ("shlib_getfunptr1 () "); + if (p == shlib_shlibvar1) + printf ("=="); + else + printf ("!="); + printf (" shlib_shlibvar1\n"); +#ifndef XCOFF_TEST + p = shlib_getfunptr2 (); + printf ("shlib_getfunptr2 () "); + if (p == main_called) + printf ("=="); + else + printf ("!="); + printf (" main_called\n"); +#endif + printf ("shlib_check () == %d\n", shlib_check ()); + printf ("visibility_check () == %d\n", visibility_check ()); + printf ("visibility_checkfunptr () == %d\n", + visibility_checkfunptr ()); + printf ("main_visibility_check () == %d\n", main_visibility_check ()); + return 0; +} |