mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-03-11 16:35:33 +00:00
Enable windows x86-32 AOT relocations (#2285)
Implement relocation types IMAGE_REL_I386_DIR32 and IMAGE_REL_I386_REL32, fix failure to find AOT function symbol, and implement symbol __aulldiv.
This commit is contained in:
parent
efaf37c577
commit
0ac5f206b8
|
@ -1996,6 +1996,20 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
|
|||
symbol_addr = module->func_ptrs[func_index];
|
||||
#endif
|
||||
}
|
||||
#if defined(BH_PLATFORM_WINDOWS) && defined(BUILD_TARGET_X86_32)
|
||||
/* AOT function name starts with '_' in windows x86-32 */
|
||||
else if (!strncmp(symbol, "_" AOT_FUNC_PREFIX,
|
||||
strlen("_" AOT_FUNC_PREFIX))) {
|
||||
p = symbol + strlen("_" AOT_FUNC_PREFIX);
|
||||
if (*p == '\0'
|
||||
|| (func_index = (uint32)atoi(p)) > module->func_count) {
|
||||
set_error_buf_v(error_buf, error_buf_size, "invalid symbol %s",
|
||||
symbol);
|
||||
goto check_symbol_fail;
|
||||
}
|
||||
symbol_addr = module->func_ptrs[func_index];
|
||||
}
|
||||
#endif
|
||||
else if (!strcmp(symbol, ".text")) {
|
||||
symbol_addr = module->code;
|
||||
}
|
||||
|
|
|
@ -5,12 +5,19 @@
|
|||
|
||||
#include "aot_reloc.h"
|
||||
|
||||
/* clang-format off */
|
||||
#if !defined(BH_PLATFORM_WINDOWS)
|
||||
#define R_386_32 1 /* Direct 32 bit */
|
||||
#define R_386_PC32 2 /* PC relative 32 bit */
|
||||
#define R_386_PLT32 4 /* 32-bit address ProcedureLinkageTable */
|
||||
#define R_386_TLS_GD_32 \
|
||||
24 /* Direct 32 bit for general dynamic \
|
||||
thread local data */
|
||||
#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic
|
||||
thread local data */
|
||||
#else
|
||||
#define IMAGE_REL_I386_DIR32 6 /* The target's 32-bit VA */
|
||||
#define IMAGE_REL_I386_REL32 20 /* The 32-bit relative displacement
|
||||
to the target */
|
||||
#endif
|
||||
/* clang-format on */
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN32_)
|
||||
/* clang-format off */
|
||||
|
@ -48,6 +55,12 @@ __umoddi3(uint64 a, uint64 b)
|
|||
}
|
||||
#endif
|
||||
|
||||
static uint64
|
||||
__aulldiv(uint64 a, uint64 b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
static SymbolMap target_sym_map[] = {
|
||||
REG_COMMON_SYMBOLS
|
||||
|
@ -55,7 +68,8 @@ static SymbolMap target_sym_map[] = {
|
|||
REG_SYM(__divdi3),
|
||||
REG_SYM(__udivdi3),
|
||||
REG_SYM(__moddi3),
|
||||
REG_SYM(__umoddi3)
|
||||
REG_SYM(__umoddi3),
|
||||
REG_SYM(__aulldiv)
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
|
@ -112,9 +126,13 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
|
|||
int32 symbol_index, char *error_buf, uint32 error_buf_size)
|
||||
{
|
||||
switch (reloc_type) {
|
||||
#if !defined(BH_PLATFORM_WINDOWS)
|
||||
case R_386_32:
|
||||
#if WASM_ENABLE_STATIC_PGO != 0
|
||||
case R_386_TLS_GD_32:
|
||||
#endif
|
||||
#else
|
||||
case IMAGE_REL_I386_DIR32:
|
||||
#endif
|
||||
{
|
||||
intptr_t value;
|
||||
|
@ -127,12 +145,16 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
|
|||
break;
|
||||
}
|
||||
|
||||
#if !defined(BH_PLATFORM_WINDOWS)
|
||||
/*
|
||||
* Handle R_386_PLT32 like R_386_PC32 since it should be able to reach
|
||||
* any 32 bit address
|
||||
*/
|
||||
case R_386_PLT32:
|
||||
case R_386_PC32:
|
||||
#else
|
||||
case IMAGE_REL_I386_REL32:
|
||||
#endif
|
||||
{
|
||||
int32 value;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user