@@ -90,7 +90,8 @@ static bool
9090check_buf (const uint8 * buf , const uint8 * buf_end , uint32 length ,
9191 char * error_buf , uint32 error_buf_size )
9292{
93- if (buf + length < buf || buf + length > buf_end ) {
93+ if ((uintptr_t )buf + length < (uintptr_t )buf
94+ || (uintptr_t )buf + length > (uintptr_t )buf_end ) {
9495 set_error_buf (error_buf , error_buf_size , "unexpect end" );
9596 return false;
9697 }
@@ -853,6 +854,7 @@ load_import_table_list(const uint8 **p_buf, const uint8 *buf_end,
853854
854855 /* keep sync with aot_emit_table_info() aot_emit_aot_file */
855856 for (i = 0 ; i < module -> import_table_count ; i ++ , import_table ++ ) {
857+ read_uint32 (buf , buf_end , import_table -> elem_type );
856858 read_uint32 (buf , buf_end , import_table -> table_init_size );
857859 read_uint32 (buf , buf_end , import_table -> table_max_size );
858860 read_uint32 (buf , buf_end , possible_grow );
@@ -1575,8 +1577,10 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, AOTModule *module,
15751577
15761578#if defined(OS_ENABLE_HW_BOUND_CHECK ) && defined(BH_PLATFORM_WINDOWS )
15771579 if (module -> func_count > 0 ) {
1580+ uint32 plt_table_size =
1581+ module -> is_indirect_mode ? 0 : get_plt_table_size ();
15781582 rtl_func_table [module -> func_count - 1 ].EndAddress =
1579- (DWORD )(module -> code_size - get_plt_table_size () );
1583+ (DWORD )(module -> code_size - plt_table_size );
15801584
15811585 if (!RtlAddFunctionTable (rtl_func_table , module -> func_count ,
15821586 (DWORD64 )(uintptr_t )module -> code )) {
@@ -2113,19 +2117,29 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
21132117 memcpy (group_name_buf , group_name , group_name_len );
21142118 memcpy (symbol_name_buf , symbol_name , symbol_name_len );
21152119
2116- if (group_name_len == strlen (".text" )
2120+ if ((group_name_len == strlen (".text" )
2121+ || (module -> is_indirect_mode
2122+ && group_name_len == strlen (".text" ) + 1 ))
21172123 && !strncmp (group_name , ".text" , strlen (".text" ))) {
2118- if (symbol_name_len == strlen (XMM_PLT_PREFIX ) + 32
2124+ if ((symbol_name_len == strlen (XMM_PLT_PREFIX ) + 32
2125+ || (module -> is_indirect_mode
2126+ && symbol_name_len == strlen (XMM_PLT_PREFIX ) + 32 + 1 ))
21192127 && !strncmp (symbol_name , XMM_PLT_PREFIX ,
21202128 strlen (XMM_PLT_PREFIX ))) {
21212129 module -> xmm_plt_count ++ ;
21222130 }
2123- else if (symbol_name_len == strlen (REAL_PLT_PREFIX ) + 16
2131+ else if ((symbol_name_len == strlen (REAL_PLT_PREFIX ) + 16
2132+ || (module -> is_indirect_mode
2133+ && symbol_name_len
2134+ == strlen (REAL_PLT_PREFIX ) + 16 + 1 ))
21242135 && !strncmp (symbol_name , REAL_PLT_PREFIX ,
21252136 strlen (REAL_PLT_PREFIX ))) {
21262137 module -> real_plt_count ++ ;
21272138 }
2128- else if (symbol_name_len == strlen (REAL_PLT_PREFIX ) + 8
2139+ else if ((symbol_name_len >= strlen (REAL_PLT_PREFIX ) + 8
2140+ || (module -> is_indirect_mode
2141+ && symbol_name_len
2142+ == strlen (REAL_PLT_PREFIX ) + 8 + 1 ))
21292143 && !strncmp (symbol_name , REAL_PLT_PREFIX ,
21302144 strlen (REAL_PLT_PREFIX ))) {
21312145 module -> float_plt_count ++ ;
@@ -2230,7 +2244,7 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
22302244#endif
22312245 ) {
22322246#if !defined(BH_PLATFORM_LINUX ) && !defined(BH_PLATFORM_LINUX_SGX ) \
2233- && !defined(BH_PLATFORM_DARWIN )
2247+ && !defined(BH_PLATFORM_DARWIN ) && !defined( BH_PLATFORM_WINDOWS )
22342248 if (module -> is_indirect_mode ) {
22352249 set_error_buf (error_buf , error_buf_size ,
22362250 "cannot apply relocation to text section "
0 commit comments