diff --git a/core/iwasm/aot/arch/aot_reloc_arm.c b/core/iwasm/aot/arch/aot_reloc_arm.c index c63deb4b..8da77a52 100644 --- a/core/iwasm/aot/arch/aot_reloc_arm.c +++ b/core/iwasm/aot/arch/aot_reloc_arm.c @@ -10,105 +10,166 @@ #define R_ARM_ABS32 2 /* Direct 32 bit */ /* clang-format off */ -void __divdi3(); -void __udivdi3(); -void __moddi3(); -void __umoddi3(); -void __divsi3(); -void __udivsi3(); -void __modsi3(); -void __umodsi3(); -void __udivmoddi4(); -void __clzsi2(); -void __fixsfdi(); -void __fixunssfdi(); -void __fixdfdi(); -void __fixunsdfdi(); -void __floatdisf(); -void __floatundisf(); -void __floatdidf(); -void __floatundidf(); -void __aeabi_l2f(); -void __aeabi_f2lz(); -void __aeabi_ul2f(); +void __adddf3(); +void __addsf3(); +void __aeabi_d2iz(); void __aeabi_d2lz(); -void __aeabi_l2d(); -void __aeabi_f2ulz(); -void __aeabi_ul2d(); void __aeabi_d2ulz(); -void __aeabi_idiv(); -void __aeabi_uidiv(); -void __aeabi_idivmod(); -void __aeabi_uidivmod(); -void __aeabi_ldivmod(); -void __aeabi_uldivmod(); -void __aeabi_i2d(); void __aeabi_dadd(); -void __aeabi_ddiv(); +void __aeabi_dcmpge(); +void __aeabi_dcmple(); void __aeabi_dcmplt(); void __aeabi_dcmpun(); -void __aeabi_dcmple(); -void __aeabi_dcmpge(); -void __aeabi_d2iz(); +void __aeabi_ddiv(); +void __aeabi_f2d(); +void __aeabi_f2iz(); +void __aeabi_f2lz(); +void __aeabi_f2ulz(); +void __aeabi_fcmpge(); +void __aeabi_fcmple(); void __aeabi_fcmplt(); void __aeabi_fcmpun(); -void __aeabi_fcmple(); -void __aeabi_fcmpge(); -void __aeabi_f2iz(); -void __aeabi_f2d(); +void __aeabi_i2d(); +void __aeabi_idiv(); +void __aeabi_idivmod(); +void __aeabi_l2d(); +void __aeabi_l2f(); +void __aeabi_ldivmod(); +void __aeabi_uidiv(); +void __aeabi_uidivmod(); +void __aeabi_ul2d(); +void __aeabi_ul2f(); +void __aeabi_uldivmod(); +void __clzsi2(); +void __divdf3(); +void __divdi3(); +void __divsf3(); +void __divsi3(); +void __eqdf2(); +void __extendsfdf2(); +void __fixdfdi(); +void __fixdfsi(); +void __fixsfdi(); +void __fixsfsi(); +void __fixunsdfdi(); +void __fixunsdfsi(); +void __fixunssfdi(); +void __floatdidf(); +void __floatdisf(); +void __floatsidf(); +void __floatsisf(); +void __floatundidf(); +void __floatundisf(); +void __floatunsidf(); +void __floatunsisf(); +void __gedf2(); +void __gesf2(); +void __gtdf2(); +void __gtsf2(); +void __ledf2(); +void __lesf2(); +void __ltdf2(); +void __ltsf2(); +void __moddi3(); +void __modsi3(); +void __muldf3(); +void __mulsf3(); +void __nedf2(); +void __nesf2(); +void __subdf3(); +void __subsf3(); +void __truncdfsf2(); +void __udivdi3(); +void __udivmoddi4(); +void __udivsi3(); +void __umoddi3(); +void __umodsi3(); +void __unorddf2(); +void __unordsf2(); /* clang-format on */ static SymbolMap target_sym_map[] = { /* clang-format off */ REG_COMMON_SYMBOLS /* compiler-rt symbols that come from compiler(e.g. gcc) */ - REG_SYM(__divdi3), + REG_SYM(__adddf3), + REG_SYM(__addsf3), /* clang-format on */ - REG_SYM(__udivdi3), - REG_SYM(__moddi3), - REG_SYM(__umoddi3), - REG_SYM(__divsi3), - REG_SYM(__udivsi3), - REG_SYM(__modsi3), - REG_SYM(__umodsi3), - REG_SYM(__udivmoddi4), - REG_SYM(__clzsi2), - REG_SYM(__fixsfdi), - REG_SYM(__fixunssfdi), - REG_SYM(__fixdfdi), - REG_SYM(__fixunsdfdi), - REG_SYM(__floatdisf), - REG_SYM(__floatundisf), - REG_SYM(__floatdidf), - REG_SYM(__floatundidf), - REG_SYM(__aeabi_l2f), - REG_SYM(__aeabi_f2lz), - REG_SYM(__aeabi_ul2f), + REG_SYM(__aeabi_d2iz), REG_SYM(__aeabi_d2lz), - REG_SYM(__aeabi_l2d), - REG_SYM(__aeabi_f2ulz), - REG_SYM(__aeabi_ul2d), REG_SYM(__aeabi_d2ulz), - REG_SYM(__aeabi_idiv), - REG_SYM(__aeabi_uidiv), - REG_SYM(__aeabi_idivmod), - REG_SYM(__aeabi_uidivmod), - REG_SYM(__aeabi_ldivmod), - REG_SYM(__aeabi_uldivmod), - REG_SYM(__aeabi_i2d), REG_SYM(__aeabi_dadd), - REG_SYM(__aeabi_ddiv), + REG_SYM(__aeabi_dcmpge), + REG_SYM(__aeabi_dcmple), REG_SYM(__aeabi_dcmplt), REG_SYM(__aeabi_dcmpun), - REG_SYM(__aeabi_dcmple), - REG_SYM(__aeabi_dcmpge), - REG_SYM(__aeabi_d2iz), + REG_SYM(__aeabi_ddiv), + REG_SYM(__aeabi_f2d), + REG_SYM(__aeabi_f2iz), + REG_SYM(__aeabi_f2lz), + REG_SYM(__aeabi_f2ulz), + REG_SYM(__aeabi_fcmpge), + REG_SYM(__aeabi_fcmple), REG_SYM(__aeabi_fcmplt), REG_SYM(__aeabi_fcmpun), - REG_SYM(__aeabi_fcmple), - REG_SYM(__aeabi_fcmpge), - REG_SYM(__aeabi_f2iz), - REG_SYM(__aeabi_f2d), + REG_SYM(__aeabi_i2d), + REG_SYM(__aeabi_idiv), + REG_SYM(__aeabi_idivmod), + REG_SYM(__aeabi_l2d), + REG_SYM(__aeabi_l2f), + REG_SYM(__aeabi_ldivmod), + REG_SYM(__aeabi_uidiv), + REG_SYM(__aeabi_uidivmod), + REG_SYM(__aeabi_ul2d), + REG_SYM(__aeabi_ul2f), + REG_SYM(__aeabi_uldivmod), + REG_SYM(__clzsi2), + REG_SYM(__divdf3), + REG_SYM(__divdi3), + REG_SYM(__divsf3), + REG_SYM(__divsi3), + REG_SYM(__eqdf2), + REG_SYM(__extendsfdf2), + REG_SYM(__fixdfdi), + REG_SYM(__fixdfsi), + REG_SYM(__fixsfdi), + REG_SYM(__fixsfsi), + REG_SYM(__fixunsdfdi), + REG_SYM(__fixunsdfsi), + REG_SYM(__fixunssfdi), + REG_SYM(__floatdidf), + REG_SYM(__floatdisf), + REG_SYM(__floatsidf), + REG_SYM(__floatsisf), + REG_SYM(__floatundidf), + REG_SYM(__floatundisf), + REG_SYM(__floatunsidf), + REG_SYM(__floatunsisf), + REG_SYM(__gedf2), + REG_SYM(__gesf2), + REG_SYM(__gtdf2), + REG_SYM(__gtsf2), + REG_SYM(__ledf2), + REG_SYM(__lesf2), + REG_SYM(__ltdf2), + REG_SYM(__ltsf2), + REG_SYM(__moddi3), + REG_SYM(__modsi3), + REG_SYM(__muldf3), + REG_SYM(__muldf3), + REG_SYM(__mulsf3), + REG_SYM(__nedf2), + REG_SYM(__nesf2), + REG_SYM(__subdf3), + REG_SYM(__subsf3), + REG_SYM(__truncdfsf2), + REG_SYM(__udivdi3), + REG_SYM(__udivmoddi4), + REG_SYM(__udivsi3), + REG_SYM(__umoddi3), + REG_SYM(__umodsi3), + REG_SYM(__unorddf2), + REG_SYM(__unordsf2), }; static void diff --git a/core/iwasm/aot/arch/aot_reloc_riscv.c b/core/iwasm/aot/arch/aot_reloc_riscv.c index 7e3e5392..d695dc73 100644 --- a/core/iwasm/aot/arch/aot_reloc_riscv.c +++ b/core/iwasm/aot/arch/aot_reloc_riscv.c @@ -17,21 +17,53 @@ /* clang-format off */ void __divdi3(); +void __divsi3(); +void __fixdfdi(); +void __fixsfdi(); +void __fixunsdfdi(); +void __fixunssfdi(); +void __floatdidf(); +void __floatdisf(); +void __floatundidf(); +void __floatundisf(); void __moddi3(); +void __modsi3(); void __muldi3(); +void __mulsi3(); void __udivdi3(); +void __udivsi3(); void __umoddi3(); +void __umodsi3(); /* clang-format on */ static SymbolMap target_sym_map[] = { /* clang-format off */ REG_COMMON_SYMBOLS REG_SYM(__divdi3), - /* clang-format on */ + REG_SYM(__divsi3), +#if __riscv_xlen == 32 + REG_SYM(__fixdfdi), + REG_SYM(__fixsfdi), +#endif + REG_SYM(__fixunsdfdi), + REG_SYM(__fixunssfdi), +#if __riscv_xlen == 32 + REG_SYM(__floatdidf), + REG_SYM(__floatdisf), + REG_SYM(__floatundidf), + REG_SYM(__floatundisf), +#endif REG_SYM(__moddi3), + REG_SYM(__modsi3), REG_SYM(__muldi3), +#if __riscv_xlen == 32 + REG_SYM(__mulsi3), +#endif REG_SYM(__udivdi3), + REG_SYM(__udivsi3), REG_SYM(__umoddi3), + REG_SYM(__umodsi3), + /* clang-format on */ }; static void diff --git a/core/iwasm/aot/arch/aot_reloc_thumb.c b/core/iwasm/aot/arch/aot_reloc_thumb.c index 350b5296..bfcf4233 100644 --- a/core/iwasm/aot/arch/aot_reloc_thumb.c +++ b/core/iwasm/aot/arch/aot_reloc_thumb.c @@ -5,138 +5,180 @@ #include "aot_reloc.h" +#define R_ARM_ABS32 2 /* Direct 32 bit */ #define R_ARM_THM_CALL 10 /* PC relative (Thumb BL and ARMv5 Thumb BLX). */ #define R_ARM_THM_JMP24 30 /* B.W */ /* clang-format off */ -void __ltdf2(); void __adddf3(); -void __eqdf2(); -void __unorddf2(); -void __muldf3(); -void __subdf3(); -void __gedf2(); -void __ledf2(); -void __fixunsdfsi(); -void __floatunsidf(); -void __fixdfsi(); -void __nedf2(); -void __floatsidf(); -void __divdi3(); -void __udivdi3(); -void __moddi3(); -void __umoddi3(); -void __divsi3(); -void __udivsi3(); -void __modsi3(); -void __udivmoddi4(); -void __clzsi2(); -void __fixsfdi(); -void __fixunssfdi(); -void __fixdfdi(); -void __fixunsdfdi(); -void __floatdisf(); -void __floatundisf(); -void __floatdidf(); -void __floatundidf(); -void __aeabi_l2f(); -void __aeabi_f2lz(); -void __aeabi_ul2f(); +void __addsf3(); +void __aeabi_d2iz(); void __aeabi_d2lz(); -void __aeabi_l2d(); -void __aeabi_f2ulz(); -void __aeabi_ul2d(); -void __aeabi_ui2d(); +void __aeabi_d2uiz(); void __aeabi_d2ulz(); -void __aeabi_idiv(); -void __aeabi_uidiv(); -void __aeabi_idivmod(); -void __aeabi_uidivmod(); -void __aeabi_ldivmod(); -void __aeabi_uldivmod(); -void __aeabi_i2d(); void __aeabi_dadd(); -void __aeabi_ddiv(); -void __aeabi_dcmplt(); -void __aeabi_dcmpun(); -void __aeabi_dcmple(); void __aeabi_dcmpge(); void __aeabi_dcmpgt(); -void __aeabi_d2iz(); -void __aeabi_d2uiz(); +void __aeabi_dcmple(); +void __aeabi_dcmplt(); +void __aeabi_dcmpun(); +void __aeabi_ddiv(); +void __aeabi_f2d(); +void __aeabi_f2iz(); +void __aeabi_f2lz(); +void __aeabi_f2ulz(); +void __aeabi_fcmpge(); +void __aeabi_fcmple(); void __aeabi_fcmplt(); void __aeabi_fcmpun(); -void __aeabi_fcmple(); -void __aeabi_fcmpge(); -void __aeabi_f2iz(); -void __aeabi_f2d(); +void __aeabi_i2d(); +void __aeabi_idiv(); +void __aeabi_idivmod(); +void __aeabi_l2d(); +void __aeabi_l2f(); +void __aeabi_ldivmod(); +void __aeabi_ui2d(); +void __aeabi_uidiv(); +void __aeabi_uidivmod(); +void __aeabi_ul2d(); +void __aeabi_ul2f(); +void __aeabi_uldivmod(); +void __ashldi3(); +void __clzsi2(); +void __divdf3(); +void __divdi3(); +void __divsi3(); +void __eqdf2(); +void __eqsf2(); +void __extendsfdf2(); +void __fixdfdi(); +void __fixdfsi(); +void __fixsfdi(); +void __fixunsdfdi(); +void __fixunsdfsi(); +void __fixunssfdi(); +void __floatdidf(); +void __floatdisf(); +void __floatsidf(); +void __floatsisf(); +void __floatundidf(); +void __floatundisf(); +void __floatunsidf(); +void __floatunsisf(); +void __gedf2(); +void __gesf2(); +void __gtdf2(); +void __gtsf2(); +void __ledf2(); +void __lesf2(); +void __lshrdi3(); +void __ltdf2(); +void __ltsf2(); +void __moddi3(); +void __modsi3(); +void __muldf3(); +void __muldi3(); +void __mulsf3(); +void __nedf2(); +void __nesf2(); +void __subdf3(); +void __subsf3(); +void __truncdfsf2(); +void __udivdi3(); +void __udivmoddi4(); +void __udivsi3(); +void __umoddi3(); +void __umodsi3(); +void __unorddf2(); +void __unordsf2(); /* clang-format on */ static SymbolMap target_sym_map[] = { /* clang-format off */ REG_COMMON_SYMBOLS /* compiler-rt symbols that come from compiler(e.g. gcc) */ - REG_SYM(__ltdf2), - /* clang-format on */ REG_SYM(__adddf3), - REG_SYM(__eqdf2), - REG_SYM(__unorddf2), - REG_SYM(__muldf3), - REG_SYM(__subdf3), - REG_SYM(__gedf2), - REG_SYM(__ledf2), - REG_SYM(__fixunsdfsi), - REG_SYM(__floatunsidf), - REG_SYM(__fixdfsi), - REG_SYM(__nedf2), - REG_SYM(__floatsidf), - REG_SYM(__divdi3), - REG_SYM(__udivdi3), - REG_SYM(__umoddi3), - REG_SYM(__divsi3), - REG_SYM(__udivsi3), - REG_SYM(__modsi3), - REG_SYM(__udivmoddi4), - REG_SYM(__clzsi2), - REG_SYM(__fixsfdi), - REG_SYM(__fixunssfdi), - REG_SYM(__fixdfdi), - REG_SYM(__fixunsdfdi), - REG_SYM(__floatdisf), - REG_SYM(__floatundisf), - REG_SYM(__floatdidf), - REG_SYM(__floatundidf), - REG_SYM(__aeabi_l2f), - REG_SYM(__aeabi_f2lz), - REG_SYM(__aeabi_ul2f), + REG_SYM(__addsf3), + /* clang-format on */ + REG_SYM(__aeabi_d2iz), REG_SYM(__aeabi_d2lz), - REG_SYM(__aeabi_l2d), - REG_SYM(__aeabi_f2ulz), - REG_SYM(__aeabi_ul2d), - REG_SYM(__aeabi_ui2d), + REG_SYM(__aeabi_d2uiz), REG_SYM(__aeabi_d2ulz), - REG_SYM(__aeabi_idiv), - REG_SYM(__aeabi_uidiv), - REG_SYM(__aeabi_idivmod), - REG_SYM(__aeabi_uidivmod), - REG_SYM(__aeabi_ldivmod), - REG_SYM(__aeabi_uldivmod), - REG_SYM(__aeabi_i2d), REG_SYM(__aeabi_dadd), - REG_SYM(__aeabi_ddiv), - REG_SYM(__aeabi_dcmplt), - REG_SYM(__aeabi_dcmpun), - REG_SYM(__aeabi_dcmple), REG_SYM(__aeabi_dcmpge), REG_SYM(__aeabi_dcmpgt), - REG_SYM(__aeabi_d2iz), - REG_SYM(__aeabi_d2uiz), + REG_SYM(__aeabi_dcmple), + REG_SYM(__aeabi_dcmplt), + REG_SYM(__aeabi_dcmpun), + REG_SYM(__aeabi_ddiv), + REG_SYM(__aeabi_f2d), + REG_SYM(__aeabi_f2iz), + REG_SYM(__aeabi_f2lz), + REG_SYM(__aeabi_f2ulz), + REG_SYM(__aeabi_fcmpge), + REG_SYM(__aeabi_fcmple), REG_SYM(__aeabi_fcmplt), REG_SYM(__aeabi_fcmpun), - REG_SYM(__aeabi_fcmple), - REG_SYM(__aeabi_fcmpge), - REG_SYM(__aeabi_f2iz), - REG_SYM(__aeabi_f2d), + REG_SYM(__aeabi_i2d), + REG_SYM(__aeabi_idiv), + REG_SYM(__aeabi_idivmod), + REG_SYM(__aeabi_l2d), + REG_SYM(__aeabi_l2f), + REG_SYM(__aeabi_ldivmod), + REG_SYM(__aeabi_ui2d), + REG_SYM(__aeabi_uidiv), + REG_SYM(__aeabi_uidivmod), + REG_SYM(__aeabi_ul2d), + REG_SYM(__aeabi_ul2f), + REG_SYM(__aeabi_uldivmod), + REG_SYM(__ashldi3), + REG_SYM(__clzsi2), + REG_SYM(__divdf3), + REG_SYM(__divdi3), + REG_SYM(__divsi3), + REG_SYM(__eqdf2), + REG_SYM(__eqsf2), + REG_SYM(__extendsfdf2), + REG_SYM(__fixdfdi), + REG_SYM(__fixdfsi), + REG_SYM(__fixsfdi), + REG_SYM(__fixunsdfdi), + REG_SYM(__fixunsdfsi), + REG_SYM(__fixunssfdi), + REG_SYM(__floatdidf), + REG_SYM(__floatdisf), + REG_SYM(__floatsidf), + REG_SYM(__floatsisf), + REG_SYM(__floatundidf), + REG_SYM(__floatundisf), + REG_SYM(__floatunsidf), + REG_SYM(__floatunsisf), + REG_SYM(__gedf2), + REG_SYM(__gesf2), + REG_SYM(__gtdf2), + REG_SYM(__gtsf2), + REG_SYM(__ledf2), + REG_SYM(__lesf2), + REG_SYM(__lshrdi3), + REG_SYM(__ltdf2), + REG_SYM(__ltsf2), + REG_SYM(__moddi3), + REG_SYM(__modsi3), + REG_SYM(__muldf3), + REG_SYM(__muldi3), + REG_SYM(__mulsf3), + REG_SYM(__nedf2), + REG_SYM(__nesf2), + REG_SYM(__subdf3), + REG_SYM(__subsf3), + REG_SYM(__truncdfsf2), + REG_SYM(__udivdi3), + REG_SYM(__udivmoddi4), + REG_SYM(__udivsi3), + REG_SYM(__umoddi3), + REG_SYM(__umodsi3), + REG_SYM(__unorddf2), + REG_SYM(__unordsf2), }; static void @@ -316,6 +358,18 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr, *(reloc_addr + 1) = (*(reloc_addr + 1) & ~0x7FF) | initial_addend_1; break; } + case R_ARM_ABS32: + { + intptr_t initial_addend; + /* (S + A) | T where T is 0 */ + CHECK_RELOC_OFFSET(sizeof(void *)); + initial_addend = + *(intptr_t *)(target_section_addr + (uint32)reloc_offset); + *(uintptr_t *)(target_section_addr + reloc_offset) = + (uintptr_t)symbol_addr + initial_addend + + (intptr_t)reloc_addend; + break; + } default: if (error_buf != NULL)