36
36
# include "cgroup.h"
37
37
# include "cgroup-utils.h"
38
38
39
- # include <dlfcn.h>
39
+ # ifndef STATIC
40
+ # include <dlfcn.h>
41
+ # endif
40
42
41
43
# define CRIU_CHECKPOINT_LOG_FILE "dump.log"
42
44
# define CRIU_RESTORE_LOG_FILE "restore.log"
@@ -105,8 +107,10 @@ cleanup_wrapper (void *p)
105
107
if (* w == NULL )
106
108
return ;
107
109
110
+ # ifndef STATIC
108
111
if ((* w )-> handle )
109
112
dlclose ((* w )-> handle );
113
+ # endif
110
114
free (* w );
111
115
libcriu_wrapper = NULL ;
112
116
}
@@ -118,20 +122,27 @@ load_wrapper (struct libcriu_wrapper_s **wrapper_out, libcrun_error_t *err)
118
122
{
119
123
cleanup_free struct libcriu_wrapper_s * wrapper = xmalloc0 (sizeof (* wrapper ));
120
124
121
- # define LOAD_CRIU_FUNCTION (X , ALLOW_NULL ) \
122
- do \
123
- { \
124
- wrapper->X = dlsym (wrapper->handle, #X); \
125
- if (! ALLOW_NULL && wrapper->X == NULL) \
126
- { \
127
- dlclose (wrapper->handle); \
128
- return crun_make_error (err, 0, "could not find symbol `%s` in `libcriu.so`", #X); \
129
- } \
130
- } while (0)
125
+ # ifdef STATIC
126
+ # define LOAD_CRIU_FUNCTION (X , ALLOW_NULL ) \
127
+ wrapper->X = &X;
128
+ # else
129
+ # define LOAD_CRIU_FUNCTION (X , ALLOW_NULL ) \
130
+ do \
131
+ { \
132
+ wrapper->X = dlsym (wrapper->handle, #X); \
133
+ if (! ALLOW_NULL && wrapper->X == NULL) \
134
+ { \
135
+ dlclose (wrapper->handle); \
136
+ return crun_make_error (err, 0, "could not find symbol `%s` in `libcriu.so`", #X); \
137
+ } \
138
+ } while (0)
139
+ # endif
131
140
141
+ # ifndef STATIC
132
142
wrapper -> handle = dlopen ("libcriu.so.2" , RTLD_NOW );
133
143
if (wrapper -> handle == NULL )
134
144
return crun_make_error (err , 0 , "could not load `libcriu.so.2`" );
145
+ # endif
135
146
136
147
LOAD_CRIU_FUNCTION (criu_add_ext_mount , false);
137
148
LOAD_CRIU_FUNCTION (criu_add_external , false);
0 commit comments