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/sh1.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/sh1.c')
-rw-r--r-- | ld/testsuite/ld-elfvsb/sh1.c | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elfvsb/sh1.c b/ld/testsuite/ld-elfvsb/sh1.c new file mode 100644 index 0000000..c4bdcc7 --- /dev/null +++ b/ld/testsuite/ld-elfvsb/sh1.c @@ -0,0 +1,215 @@ +/* This is part of the shared library ld test. This file becomes part + of a shared library. */ + +/* This variable is supplied by the main program. */ +#ifndef XCOFF_TEST +extern int mainvar; +#endif + +/* This variable is defined in the shared library, and overridden by + the main program. */ +#ifndef XCOFF_TEST +int overriddenvar = -1; +#endif + +/* This variable is defined in the shared library. */ +int shlibvar1 = 3; + +/* This variable is defined by another object in the shared library. */ +extern int shlibvar2; + +/* These functions return the values of the above variables as seen in + the shared library. */ + +#ifndef XCOFF_TEST +int +shlib_mainvar () +{ + return mainvar; +} +#endif + +#ifndef XCOFF_TEST +int +shlib_overriddenvar () +{ + return overriddenvar; +} +#endif + +int +shlib_shlibvar1 () +{ + return shlibvar1; +} + +int +shlib_shlibvar2 () +{ + return shlibvar2; +} + +/* This function calls a function defined by another object in the + shared library. */ + +extern int shlib_shlibcalled (); + +int +shlib_shlibcall () +{ + return shlib_shlibcalled (); +} + +#ifndef XCOFF_TEST +/* This function calls a function defined in this object in the shared + library. The main program will override the called function. */ + +extern int shlib_overriddencall2 (); + +int +shlib_shlibcall2 () +{ + return shlib_overriddencall2 (); +} + +int +shlib_overriddencall2 () +{ + return 7; +} +#endif + +/* This function calls a function defined by the main program. */ + +#ifndef XCOFF_TEST +extern int main_called (); + +int +shlib_maincall () +{ + return main_called (); +} +#endif + +/* This function is passed a function pointer to shlib_mainvar. It + confirms that the pointer compares equally. */ + +int +shlib_checkfunptr1 (p) + int (*p) (); +{ + return p == shlib_shlibvar1; +} + +/* This function is passed a function pointer to main_called. It + confirms that the pointer compares equally. */ + +#ifndef XCOFF_TEST +int +shlib_checkfunptr2 (p) + int (*p) (); +{ + return p == main_called; +} +#endif + +/* This function returns a pointer to shlib_mainvar. */ + +int +(*shlib_getfunptr1 ()) () +{ + return shlib_shlibvar1; +} + +/* This function returns a pointer to main_called. */ + +#ifndef XCOFF_TEST +int +(*shlib_getfunptr2 ()) () +{ + return main_called; +} +#endif + +/* This function makes sure that constant data and local functions + work. */ + +#ifndef __STDC__ +#define const +#endif + +static int i = 6; +static const char *str = "Hello, world\n"; + +int +shlib_check () +{ + const char *s1, *s2; + + if (i != 6) + return 0; + + /* To isolate the test, don't rely on any external functions, such + as strcmp. */ + s1 = "Hello, world\n"; + s2 = str; + while (*s1 != '\0') + if (*s1++ != *s2++) + return 0; + if (*s2 != '\0') + return 0; + + if (shlib_shlibvar1 () != 3) + return 0; + + return 1; +} + +int +visibility () +{ + return 2; +} + +#ifdef HIDDEN_NORMAL_TEST +asm (".hidden visibility_normal"); + +int +visibility_normal () +{ + return 2; +} +#endif + +int +visibility_checkfunptr () +{ +#ifdef HIDDEN_NORMAL_TEST + int (*v) () = visibility_normal; +#else + int (*v) () = visibility; +#endif + return (*v) () == 2; +} + +int +visibility_check () +{ +#ifdef HIDDEN_NORMAL_TEST + return visibility_normal () == 2; +#else + return visibility () == 2; +#endif +} + +void * +visibility_funptr () +{ + return visibility; +} + +#ifdef HIDDEN_TEST +asm (".hidden visibility"); +#else +asm (".protected visibility"); +#endif |