| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <dlfcn.h> | 
|  | 2 | #include <mcheck.h> | 
|  | 3 | #include <stdio.h> | 
|  | 4 | #include <stdlib.h> | 
|  | 5 |  | 
|  | 6 |  | 
|  | 7 | static int | 
|  | 8 | do_test (void) | 
|  | 9 | { | 
|  | 10 | void *h; | 
|  | 11 | int (*fp) (int); | 
|  | 12 | int result; | 
|  | 13 |  | 
|  | 14 | mtrace (); | 
|  | 15 |  | 
|  | 16 | h = dlopen ("renamed.so", RTLD_LAZY); | 
|  | 17 | if (h == NULL) | 
|  | 18 | { | 
|  | 19 | printf ("failed to load \"%s\": %s\n", "renamed.so", dlerror ()); | 
|  | 20 | exit (1); | 
|  | 21 | } | 
|  | 22 |  | 
|  | 23 | fp = dlsym (h, "in_renamed"); | 
|  | 24 | if (fp == NULL) | 
|  | 25 | { | 
|  | 26 | printf ("lookup of \"%s\" failed: %s\n", "in_renamed", dlerror ()); | 
|  | 27 | exit (1); | 
|  | 28 | } | 
|  | 29 |  | 
|  | 30 | result = fp (10); | 
|  | 31 |  | 
|  | 32 | if (dlclose (h) != 0) | 
|  | 33 | { | 
|  | 34 | printf ("failed to close \"%s\": %s\n", "renamed.so", dlerror ()); | 
|  | 35 | exit (1); | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | return result; | 
|  | 39 | } | 
|  | 40 |  | 
|  | 41 | #define TEST_FUNCTION do_test () | 
|  | 42 | #include "../test-skeleton.c" |