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
65
66
67
68
69
70
71
72
73
74
75
|
#include "u.h"
#include "../port/lib.h"
#include "../port/error.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include <a.out.h>
#include <dynld.h>
#include <kernel.h>
/*
* kernel interface to dynld, for use by devdynld.c,
* libinterp/dlm.c, and possibly others
*/
typedef struct Fd Fd;
struct Fd {
int fd;
};
static long
readfd(void *a, void *buf, long nbytes)
{
return kread(((Fd*)a)->fd, buf, nbytes);
}
static vlong
seekfd(void *a, vlong off, int t)
{
return kseek(((Fd*)a)->fd, off, t);
}
static void
errfd(char *s)
{
kstrcpy(up->env->errstr, s, ERRMAX);
}
Dynobj*
kdynloadfd(int fd, Dynsym *tab, int ntab)
{
Fd f;
f.fd = fd;
return dynloadgen(&f, readfd, seekfd, errfd, tab, ntab, 0);
}
int
kdynloadable(int fd)
{
Fd f;
f.fd = fd;
return dynloadable(&f, readfd, seekfd);
}
/* auxiliary routines for dynamic loading of C modules */
Dynobj*
dynld(int fd)
{
Fd f;
f.fd = fd;
return dynloadgen(&f, readfd, seekfd, errfd, _exporttab, dyntabsize(_exporttab), 0);
}
int
dynldable(int fd)
{
Fd f;
f.fd = fd;
return dynloadable(&f, readfd, seekfd);
}
|