|
|
@@ -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;
|
|
|
|