summaryrefslogtreecommitdiffhomepage
path: root/src/ldso/nt64/dynlink.c
blob: edfa4a8d5c1b777e1d81f59178c467e13a7099fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#define _BSD_SOURCE

#include <dlfcn.h>
#include "psxglue.h"
#include "pthread_impl.h"

extern struct __ldso_vtbl * __ldso_vtbl;

int __dladdr(const void * addr, Dl_info * info)
{
	return __ldso_vtbl->dladdr(addr,info);
}

int __dlinfo(void * dso, int req, void * res)
{
	return __ldso_vtbl->dlinfo(dso,req,res);
}

void *__dlsym(void * restrict p, const char * restrict s, void * restrict ra)
{
	return __ldso_vtbl->dlsym(p,s,ra);
}

void * dlopen(const char * file, int mode)
{
	return __ldso_vtbl->dlopen(file,mode);
}

int dlclose(void *p)
{
        return __ldso_vtbl->dlclose(p);
}

char * dlerror(void)
{
	return __ldso_vtbl->dlerror();
}

void __reset_tls(void)
{
	__ldso_vtbl->reset_tls();
}

void *__copy_tls(unsigned char * mem)
{
	/**
	 * this is always the simple case, since:
	 * emutls is based on PE named sections; and
	 * tls allocation and initialization are handled by clone(2)
	**/

        pthread_t td;
	uintptr_t addr;

	addr = (uintptr_t)mem;
	addr >>= 4;
	addr <<= 4;
	addr +=  16;

	td = (struct __pthread *)addr;
	td->dtv = 0;

	return td;
}