@@ -920,9 +920,14 @@ get_relocations_size(AOTObjectData *obj_data,
920920 /* ignore the relocations to aot_func_internal#n in text section
921921 for windows platform since they will be applied in
922922 aot_emit_text_section */
923+
924+ const char * name = relocation -> symbol_name ;
925+ if (name && obj_data -> target_info .bin_type == AOT_COFF32_BIN_TYPE && * name == '_' ) {
926+ name ++ ;
927+ }
923928 if ((!strcmp (relocation_group -> section_name , ".text" )
924929 || !strcmp (relocation_group -> section_name , ".ltext" ))
925- && !strncmp (relocation -> symbol_name , AOT_FUNC_INTERNAL_PREFIX ,
930+ && !strncmp (name , AOT_FUNC_INTERNAL_PREFIX ,
926931 strlen (AOT_FUNC_INTERNAL_PREFIX ))
927932 && ((!strncmp (obj_data -> comp_ctx -> target_arch , "x86_64" , 6 )
928933 /* Windows AOT_COFF64_BIN_TYPE */
@@ -2489,7 +2494,11 @@ aot_emit_text_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
24892494 relocation_count = relocation_group -> relocation_count ;
24902495 for (j = 0 ; j < relocation_count ; j ++ ) {
24912496 /* relocation to aot_func_internal#n */
2492- if (str_starts_with (relocation -> symbol_name ,
2497+ const char * name = relocation -> symbol_name ;
2498+ if (name && obj_data -> target_info .bin_type == AOT_COFF32_BIN_TYPE && * name == '_' ) {
2499+ name ++ ;
2500+ }
2501+ if (str_starts_with (name ,
24932502 AOT_FUNC_INTERNAL_PREFIX )
24942503 && ((obj_data -> target_info .bin_type
24952504 == 6 /* AOT_COFF64_BIN_TYPE */
@@ -2500,7 +2509,7 @@ aot_emit_text_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
25002509 && relocation -> relocation_type
25012510 == 20 /* IMAGE_REL_I386_REL32 */ ))) {
25022511 uint32 func_idx =
2503- atoi (relocation -> symbol_name
2512+ atoi (name
25042513 + strlen (AOT_FUNC_INTERNAL_PREFIX ));
25052514 uint64 text_offset , reloc_offset , reloc_addend ;
25062515
@@ -3695,8 +3704,11 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
36953704 }
36963705
36973706 while (!LLVMObjectFileIsSymbolIteratorAtEnd (obj_data -> binary , sym_itr )) {
3698- if ((name = (char * )LLVMGetSymbolName (sym_itr ))
3699- && str_starts_with (name , prefix )) {
3707+ name = (char * )LLVMGetSymbolName (sym_itr );
3708+ if (name && obj_data -> target_info .bin_type == AOT_COFF32_BIN_TYPE && * name == '_' ) {
3709+ name ++ ;
3710+ }
3711+ if (name && str_starts_with (name , prefix )) {
37003712 /* symbol aot_func#n */
37013713 func_index = (uint32 )atoi (name + strlen (prefix ));
37023714 if (func_index < obj_data -> func_count ) {
@@ -3734,8 +3746,7 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
37343746 }
37353747 }
37363748 }
3737- else if ((name = (char * )LLVMGetSymbolName (sym_itr ))
3738- && str_starts_with (name , AOT_FUNC_INTERNAL_PREFIX )) {
3749+ else if (name && str_starts_with (name , AOT_FUNC_INTERNAL_PREFIX )) {
37393750 /* symbol aot_func_internal#n */
37403751 func_index = (uint32 )atoi (name + strlen (AOT_FUNC_INTERNAL_PREFIX ));
37413752 if (func_index < obj_data -> func_count ) {
0 commit comments