OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [linux/] [uClibc/] [test/] [dlopen/] [dltest.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
#include <fcntl.h>
2
#include <stdlib.h>
3
#include <stdio.h>
4
#include <dlfcn.h>
5
#include <stdint.h>
6
 
7
#ifdef __UCLIBC__
8
extern void _dlinfo(void);
9
#endif
10
 
11
int main(int argc, char **argv)
12
{
13
        int ret = EXIT_SUCCESS;
14
        void *handle;
15
        void (*mydltest)(void *value1, void *value2);
16
        char *error;
17
        uint32_t *value1, *value2;
18
 
19
        handle = dlopen (LIBNAME, RTLD_LAZY);
20
        if (!handle) {
21
                fprintf(stderr, "Could not open ./libtest.so: %s\n", dlerror());
22
                exit(1);
23
        }
24
 
25
        mydltest = dlsym(handle, "dltest");
26
        if ((error = dlerror()) != NULL)  {
27
                fprintf(stderr, "Could not locate symbol 'dltest': %s\n", error);
28
                exit(1);
29
        }
30
 
31
        mydltest(&value1, &value2);
32
        printf("dltest: __pthread_once=%p\n", value1);
33
        printf("dltest: pthread_self=%p\n", value2);
34
        if (value1 == value2) {
35
            ret = EXIT_FAILURE;
36
            printf("dltest: values should NOT be equal  Weak values resolved incorrectly!\n");
37
        } else {
38
            printf("dltest: weak symbols resoved correctly.\n");
39
        }
40
 
41
        dlclose(handle);
42
 
43
        return ret;
44
}
45
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.