Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
glibc/dlfcn/defaultmod2.c
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
71 lines (63 sloc)
1.42 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dlfcn.h> | |
#include <stdio.h> | |
extern int found_in_mod1 (void); | |
int | |
found_in_mod1 (void) | |
{ | |
return 1; | |
} | |
extern int found_in_mod2 (void); | |
int | |
found_in_mod2 (void) | |
{ | |
return 2; | |
} | |
extern int test_in_mod2 (int (*mainp)(int, char **)); | |
int | |
test_in_mod2 (int (*mainp)(int, char **)) | |
{ | |
int (*ifp) (void); | |
void *p; | |
int result = 0; | |
/* Find function `main'. */ | |
p = dlsym (RTLD_DEFAULT, "main"); | |
if (p == NULL) | |
{ | |
printf ("%s: main not found\n", __FILE__); | |
result = 1; | |
} | |
else if ((int (*)(int, char **))p != mainp) | |
{ | |
printf ("%s: wrong address returned for main\n", __FILE__); | |
result = 1; | |
} | |
else | |
printf ("%s: main correctly found\n", __FILE__); | |
ifp = dlsym (RTLD_DEFAULT, "found_in_mod1"); | |
if ((void *) ifp == NULL) | |
{ | |
printf ("%s: found_in_mod1 not found\n", __FILE__); | |
result = 1; | |
} | |
else if (ifp () != 1) | |
{ | |
printf ("%s: wrong address returned for found_in_mod1\n", __FILE__); | |
result = 1; | |
} | |
else | |
printf ("%s: found_in_mod1 correctly found\n", __FILE__); | |
ifp = dlsym (RTLD_DEFAULT, "found_in_mod2"); | |
if ((void *) ifp == NULL) | |
{ | |
printf ("%s: found_in_mod2 not found\n", __FILE__); | |
result = 1; | |
} | |
else if (ifp () != 2) | |
{ | |
printf ("%s: wrong address returned for found_in_mod2\n", __FILE__); | |
result = 1; | |
} | |
else | |
printf ("%s: found_in_mod2 correctly found\n", __FILE__); | |
return result; | |
} |