mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-17 01:38:15 +00:00

By this patch, an experimental shared-everything modules linking is supported, typically user could use the feature to dlopen a wasm/aot module, then get the funcref by dlsym, and call the target function by call indirect instr. Of course, a dlclose is supported too. Currently, root module could be a regular module, wasi module, or AssemblyScript module; dependency module MUST be a module built followed the proposal "dynamical linking", that means it should contain a new dylink section and no mem allocator function exported. User could get it by clang or emcc. New iwasm switch --enable-dopen is used for enabling the feature and choosing the launch mode. see the iwasm -h for details. Multiple modules feature is not well tested, there should be some cases not covered. Co-authored-by: jhe <hejie.he@antgroup.com>
63 lines
1.6 KiB
C
63 lines
1.6 KiB
C
/*
|
|
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
*/
|
|
|
|
#ifndef _LIB_EXPORT_H_
|
|
#define _LIB_EXPORT_H_
|
|
|
|
#include <stdint.h>
|
|
#include "ConstStrDesc.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef union {
|
|
const char *symbol_str;
|
|
const ConstStrDescription * symbol;
|
|
uint32 symbol_key;
|
|
} NATIVE_SYMBOL_U;
|
|
|
|
typedef struct NativeSymbol {
|
|
NATIVE_SYMBOL_U u;
|
|
void *func_ptr;
|
|
const char *signature;
|
|
/* attachment which can be retrieved in native API by
|
|
calling wasm_runtime_get_function_attachment(exec_env) */
|
|
void *attachment;
|
|
} NativeSymbol;
|
|
|
|
/* clang-format off */
|
|
#define EXPORT_WASM_API(symbol) \
|
|
{ #symbol, (void *)symbol, NULL, NULL }
|
|
#define EXPORT_WASM_API2(symbol) \
|
|
{ #symbol, (void *)symbol##_wrapper, NULL, NULL }
|
|
|
|
#define EXPORT_WASM_API_WITH_SIG(symbol, signature) \
|
|
{ #symbol, (void *)symbol, signature, NULL }
|
|
#define EXPORT_WASM_API_WITH_SIG2(symbol, signature) \
|
|
{ #symbol, (void *)symbol##_wrapper, signature, NULL }
|
|
|
|
#define EXPORT_WASM_API_WITH_ATT(symbol, signature, attachment) \
|
|
{ #symbol, (void *)symbol, signature, attachment }
|
|
#define EXPORT_WASM_API_WITH_ATT2(symbol, signature, attachment) \
|
|
{ #symbol, (void *)symbol##_wrapper, signature, attachment }
|
|
/* clang-format on */
|
|
|
|
/**
|
|
* Get the exported APIs of base lib
|
|
*
|
|
* @param p_base_lib_apis return the exported API array of base lib
|
|
*
|
|
* @return the number of the exported API
|
|
*/
|
|
uint32_t
|
|
get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* end of _LIB_EXPORT_H_ */
|