author | Hajime Tazaki <tazaki@sfc.wide.ad.jp> |
Mon, 01 Jun 2015 14:21:35 +0900 | |
changeset 664 | 213835f32c54 |
parent 571 | 2e0bc0692dfd |
permissions | -rw-r--r-- |
533 | 1 |
#ifndef VDL_CONTEXT_H |
2 |
#define VDL_CONTEXT_H |
|
3 |
||
4 |
#include <stdint.h> |
|
538
35d137b26ca1
cleanup vdl.h API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
533
diff
changeset
|
5 |
#include <stdbool.h> |
533 | 6 |
|
7 |
struct VdlList; |
|
8 |
struct VdlFile; |
|
9 |
||
10 |
struct VdlContextSymbolRemapEntry |
|
11 |
{ |
|
12 |
char *src_name; |
|
13 |
char *src_ver_name; |
|
14 |
char *src_ver_filename; |
|
15 |
char *dst_name; |
|
16 |
char *dst_ver_name; |
|
17 |
char *dst_ver_filename; |
|
18 |
}; |
|
19 |
struct VdlContextLibRemapEntry |
|
20 |
{ |
|
21 |
char *src; |
|
22 |
char *dst; |
|
23 |
}; |
|
24 |
||
25 |
enum VdlEvent { |
|
26 |
VDL_EVENT_MAPPED, |
|
571
2e0bc0692dfd
gah, forgot to update enum
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
27 |
VDL_EVENT_UNMAPPED, |
533 | 28 |
VDL_EVENT_CONSTRUCTED, |
29 |
VDL_EVENT_DESTROYED |
|
30 |
}; |
|
31 |
struct VdlContextEventCallbackEntry |
|
32 |
{ |
|
33 |
void (*fn) (void *handle, enum VdlEvent event, void *context); |
|
34 |
void *context; |
|
35 |
}; |
|
36 |
||
37 |
struct VdlContext |
|
38 |
{ |
|
538
35d137b26ca1
cleanup vdl.h API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
533
diff
changeset
|
39 |
// the list of files loaded in this context |
35d137b26ca1
cleanup vdl.h API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
533
diff
changeset
|
40 |
struct VdlList *loaded; |
35d137b26ca1
cleanup vdl.h API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
533
diff
changeset
|
41 |
// the list of files which are part of the global scope of this context |
35d137b26ca1
cleanup vdl.h API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
533
diff
changeset
|
42 |
// this set is necessarily a subset of the set of loaded files |
533 | 43 |
struct VdlList *global_scope; |
44 |
// describe which symbols should be remapped to which |
|
45 |
// other symbols during symbol resolution |
|
46 |
struct VdlList *symbol_remaps; |
|
47 |
// describe which libraries should be remapped to which |
|
48 |
// other libraries during loading |
|
49 |
struct VdlList *lib_remaps; |
|
50 |
// report events within this context |
|
51 |
struct VdlList *event_callbacks; |
|
52 |
// These variables are used by all .init functions |
|
53 |
// _some_ libc .init functions make use of these |
|
54 |
// 3 arguments so, even though no one else uses them, |
|
55 |
// we have to pass them around. |
|
56 |
int argc; |
|
57 |
char **argv; |
|
58 |
char **envp; |
|
59 |
}; |
|
60 |
||
61 |
struct VdlContext *vdl_context_new (int argc, char **argv, char **envp); |
|
62 |
void vdl_context_delete (struct VdlContext *context); |
|
538
35d137b26ca1
cleanup vdl.h API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
533
diff
changeset
|
63 |
void vdl_context_add_file (struct VdlContext *context, |
35d137b26ca1
cleanup vdl.h API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
533
diff
changeset
|
64 |
struct VdlFile *file); |
35d137b26ca1
cleanup vdl.h API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
533
diff
changeset
|
65 |
void vdl_context_remove_file (struct VdlContext *context, |
35d137b26ca1
cleanup vdl.h API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
533
diff
changeset
|
66 |
struct VdlFile *file); |
533 | 67 |
void vdl_context_add_lib_remap (struct VdlContext *context, const char *src, const char *dst); |
68 |
void vdl_context_add_symbol_remap (struct VdlContext *context, |
|
69 |
const char *src_name, |
|
70 |
const char *src_ver_name, |
|
71 |
const char *src_ver_filename, |
|
72 |
const char *dst_name, |
|
73 |
const char *dst_ver_name, |
|
74 |
const char *dst_ver_filename); |
|
75 |
void vdl_context_add_callback (struct VdlContext *context, |
|
76 |
void (*cb) (void *handle, enum VdlEvent event, void *context), |
|
77 |
void *cb_context); |
|
78 |
void vdl_context_notify (struct VdlContext *context, |
|
79 |
struct VdlFile *file, |
|
80 |
enum VdlEvent event); |
|
81 |
const char *vdl_context_lib_remap (const struct VdlContext *context, const char *name); |
|
82 |
void vdl_context_symbol_remap (const struct VdlContext *context, |
|
83 |
const char **name, |
|
84 |
const char **ver_name, |
|
85 |
const char **ver_filename); |
|
86 |
||
538
35d137b26ca1
cleanup vdl.h API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
533
diff
changeset
|
87 |
bool vdl_context_empty (const struct VdlContext *context); |
533 | 88 |
|
89 |
#endif /* VDL_CONTEXT_H */ |