@@ -42,7 +42,7 @@ use crate::{
42
42
use wasmer_types:: ModuleHash ;
43
43
44
44
pub use super :: handles:: * ;
45
- use super :: { conv_env_vars, Linker , ModuleHandle , WasiState , MAIN_MODULE_HANDLE } ;
45
+ use super :: { conv_env_vars, Linker , WasiState } ;
46
46
47
47
/// Data required to construct a [`WasiEnv`].
48
48
#[ derive( Debug ) ]
@@ -154,12 +154,6 @@ pub struct WasiEnv {
154
154
/// Implementation of the WASI runtime.
155
155
pub runtime : Arc < dyn Runtime + Send + Sync + ' static > ,
156
156
157
- /// The handle of the current module in the Linker. If the module is
158
- /// statically linked, this will always be `MAIN_MODULE_HANDLE` which is
159
- /// zero. Non-zero handles will correspond to the module's entry in the
160
- /// linker, which will live in the `WasiEnv::inner` field.
161
- pub dl_handle : ModuleHandle ,
162
-
163
157
pub capabilities : Capabilities ,
164
158
165
159
/// Is this environment capable and setup for deep sleeping
@@ -211,7 +205,6 @@ impl Clone for WasiEnv {
211
205
inner : Default :: default ( ) ,
212
206
owned_handles : self . owned_handles . clone ( ) ,
213
207
runtime : self . runtime . clone ( ) ,
214
- dl_handle : self . dl_handle ,
215
208
capabilities : self . capabilities . clone ( ) ,
216
209
enable_deep_sleep : self . enable_deep_sleep ,
217
210
enable_journal : self . enable_journal ,
@@ -253,10 +246,6 @@ impl WasiEnv {
253
246
inner : Default :: default ( ) ,
254
247
owned_handles : Vec :: new ( ) ,
255
248
runtime : self . runtime . clone ( ) ,
256
- // A fork is meant to support a new process, so presumably, the first
257
- // env should be created for the main module of that process. Hence,
258
- // we set the dl_handle back to the main module's handle.
259
- dl_handle : MAIN_MODULE_HANDLE ,
260
249
capabilities : self . capabilities . clone ( ) ,
261
250
enable_deep_sleep : self . enable_deep_sleep ,
262
251
enable_journal : self . enable_journal ,
@@ -405,9 +394,6 @@ impl WasiEnv {
405
394
. threading
406
395
. enable_exponential_cpu_backoff ,
407
396
runtime : init. runtime ,
408
- // Since we're just initializing the env, the first module (to which
409
- // the new env belongs) should be the main
410
- dl_handle : MAIN_MODULE_HANDLE ,
411
397
bin_factory : init. bin_factory ,
412
398
capabilities : init. capabilities ,
413
399
disable_fs_cleanup : false ,
@@ -566,6 +552,9 @@ impl WasiEnv {
566
552
567
553
// If this module exports an _initialize function, run that first.
568
554
if call_initialize {
555
+ // This function is exported from PIE executables, and needs to be run before calling
556
+ // _initialize or _start. More info:
557
+ // https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
569
558
if let Ok ( apply_data_relocs) = instance. exports . get_function ( "__wasm_apply_data_relocs" )
570
559
{
571
560
if let Err ( err) = crate :: run_wasi_func_start ( apply_data_relocs, & mut store) {
0 commit comments