mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
f9c3e5871e
shared libraries.
64 lines
1.7 KiB
C
64 lines
1.7 KiB
C
/* 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 ();
|
|
|
|
/* This function is called by the shared library. */
|
|
|
|
int
|
|
main_called ()
|
|
{
|
|
return 6;
|
|
}
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int (*p) ();
|
|
|
|
printf ("mainvar == %d\n", mainvar);
|
|
printf ("overriddenvar == %d\n", overriddenvar);
|
|
printf ("shlibvar1 == %d\n", shlibvar1);
|
|
printf ("shlib_mainvar () == %d\n", shlib_mainvar ());
|
|
printf ("shlib_overriddenvar () == %d\n", shlib_overriddenvar ());
|
|
printf ("shlib_shlibvar1 () == %d\n", shlib_shlibvar1 ());
|
|
printf ("shlib_shlibvar2 () == %d\n", shlib_shlibvar2 ());
|
|
printf ("shlib_shlibcall () == %d\n", shlib_shlibcall ());
|
|
printf ("shlib_maincall () == %d\n", shlib_maincall ());
|
|
printf ("shlib_checkfunptr1 (shlib_mainvar) == %d\n",
|
|
shlib_checkfunptr1 (shlib_mainvar));
|
|
printf ("shlib_checkfunptr2 (main_called) == %d\n",
|
|
shlib_checkfunptr2 (main_called));
|
|
p = shlib_getfunptr1 ();
|
|
printf ("shlib_getfunptr1 () ");
|
|
if (p == shlib_mainvar)
|
|
printf ("==");
|
|
else
|
|
printf ("!=");
|
|
printf (" shlib_mainvar\n");
|
|
p = shlib_getfunptr2 ();
|
|
printf ("shlib_getfunptr2 () ");
|
|
if (p == main_called)
|
|
printf ("==");
|
|
else
|
|
printf ("!=");
|
|
printf (" main_called\n");
|
|
printf ("shlib_check () == %d\n", shlib_check ());
|
|
return 0;
|
|
}
|