aot: Avoid possible relocations around "stack_sizes" for XIP mode (#2322)
Fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/2316 Lightly tested on riscv64 qemu.
This commit is contained in:
@ -1843,6 +1843,13 @@ get_data_section_addr(AOTModule *module, const char *section_name,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const void *
|
||||
aot_get_data_section_addr(AOTModule *module, const char *section_name,
|
||||
uint32 *p_data_size)
|
||||
{
|
||||
return get_data_section_addr(module, section_name, p_data_size);
|
||||
}
|
||||
|
||||
static void *
|
||||
resolve_target_sym(const char *symbol, int32 *p_index)
|
||||
{
|
||||
|
||||
@ -42,6 +42,8 @@ bh_static_assert(offsetof(AOTModuleInstance, cur_exception)
|
||||
bh_static_assert(offsetof(AOTModuleInstance, global_table_data)
|
||||
== 13 * sizeof(uint64) + 128 + 11 * sizeof(uint64));
|
||||
|
||||
bh_static_assert(offsetof(AOTModuleInstanceExtra, stack_sizes) == 0);
|
||||
|
||||
static void
|
||||
set_error_buf(char *error_buf, uint32 error_buf_size, const char *string)
|
||||
{
|
||||
@ -1210,6 +1212,9 @@ aot_instantiate(AOTModule *module, bool is_sub_inst, WASMExecEnv *exec_env_main,
|
||||
#endif
|
||||
module_inst->default_wasm_stack_size = stack_size;
|
||||
|
||||
((AOTModuleInstanceExtra *)module_inst->e)->stack_sizes =
|
||||
aot_get_data_section_addr(module, AOT_STACK_SIZES_SECTION_NAME, NULL);
|
||||
|
||||
#if WASM_ENABLE_PERF_PROFILING != 0
|
||||
total_size = (uint64)sizeof(AOTFuncPerfProfInfo)
|
||||
* (module->import_func_count + module->func_count);
|
||||
|
||||
@ -88,6 +88,7 @@ typedef struct AOTFunctionInstance {
|
||||
} AOTFunctionInstance;
|
||||
|
||||
typedef struct AOTModuleInstanceExtra {
|
||||
DefPointer(const uint32 *, stack_sizes);
|
||||
CApiFuncImport *c_api_func_imports;
|
||||
} AOTModuleInstanceExtra;
|
||||
|
||||
@ -633,6 +634,10 @@ aot_dump_perf_profiling(const AOTModuleInstance *module_inst);
|
||||
const uint8 *
|
||||
aot_get_custom_section(const AOTModule *module, const char *name, uint32 *len);
|
||||
|
||||
const void *
|
||||
aot_get_data_section_addr(AOTModule *module, const char *section_name,
|
||||
uint32 *p_data_size);
|
||||
|
||||
#if WASM_ENABLE_STATIC_PGO != 0
|
||||
void
|
||||
llvm_profile_instrument_target(uint64 target_value, void *data,
|
||||
|
||||
Reference in New Issue
Block a user