@@ -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 }
@@ -1575,8 +1576,10 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, AOTModule *module,
15751576
15761577#if defined(OS_ENABLE_HW_BOUND_CHECK ) && defined(BH_PLATFORM_WINDOWS )
15771578 if (module -> func_count > 0 ) {
1579+ uint32 plt_table_size =
1580+ module -> is_indirect_mode ? 0 : get_plt_table_size ();
15781581 rtl_func_table [module -> func_count - 1 ].EndAddress =
1579- (DWORD )(module -> code_size - get_plt_table_size () );
1582+ (DWORD )(module -> code_size - plt_table_size );
15801583
15811584 if (!RtlAddFunctionTable (rtl_func_table , module -> func_count ,
15821585 (DWORD64 )(uintptr_t )module -> code )) {
@@ -2113,19 +2116,29 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
21132116 memcpy (group_name_buf , group_name , group_name_len );
21142117 memcpy (symbol_name_buf , symbol_name , symbol_name_len );
21152118
2116- if (group_name_len == strlen (".text" )
2119+ if ((group_name_len == strlen (".text" )
2120+ || (module -> is_indirect_mode
2121+ && group_name_len == strlen (".text" ) + 1 ))
21172122 && !strncmp (group_name , ".text" , strlen (".text" ))) {
2118- if (symbol_name_len == strlen (XMM_PLT_PREFIX ) + 32
2123+ if ((symbol_name_len == strlen (XMM_PLT_PREFIX ) + 32
2124+ || (module -> is_indirect_mode
2125+ && symbol_name_len == strlen (XMM_PLT_PREFIX ) + 32 + 1 ))
21192126 && !strncmp (symbol_name , XMM_PLT_PREFIX ,
21202127 strlen (XMM_PLT_PREFIX ))) {
21212128 module -> xmm_plt_count ++ ;
21222129 }
2123- else if (symbol_name_len == strlen (REAL_PLT_PREFIX ) + 16
2130+ else if ((symbol_name_len == strlen (REAL_PLT_PREFIX ) + 16
2131+ || (module -> is_indirect_mode
2132+ && symbol_name_len
2133+ == strlen (REAL_PLT_PREFIX ) + 16 + 1 ))
21242134 && !strncmp (symbol_name , REAL_PLT_PREFIX ,
21252135 strlen (REAL_PLT_PREFIX ))) {
21262136 module -> real_plt_count ++ ;
21272137 }
2128- else if (symbol_name_len == strlen (REAL_PLT_PREFIX ) + 8
2138+ else if ((symbol_name_len >= strlen (REAL_PLT_PREFIX ) + 8
2139+ || (module -> is_indirect_mode
2140+ && symbol_name_len
2141+ == strlen (REAL_PLT_PREFIX ) + 8 + 1 ))
21292142 && !strncmp (symbol_name , REAL_PLT_PREFIX ,
21302143 strlen (REAL_PLT_PREFIX ))) {
21312144 module -> float_plt_count ++ ;
@@ -2230,7 +2243,7 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
22302243#endif
22312244 ) {
22322245#if !defined(BH_PLATFORM_LINUX ) && !defined(BH_PLATFORM_LINUX_SGX ) \
2233- && !defined(BH_PLATFORM_DARWIN )
2246+ && !defined(BH_PLATFORM_DARWIN ) && !defined( BH_PLATFORM_WINDOWS )
22342247 if (module -> is_indirect_mode ) {
22352248 set_error_buf (error_buf , error_buf_size ,
22362249 "cannot apply relocation to text section "
0 commit comments