@@ -149,17 +149,17 @@ static void dump_buf(uint8 *buf, uint32 size, char *title)
149149#endif
150150
151151static bool
152- is_32bit_binary (LLVMBinaryRef binary )
152+ is_32bit_binary (const AOTObjectData * obj_data )
153153{
154- LLVMBinaryType type = LLVMBinaryGetType ( binary );
155- return ( type == LLVMBinaryTypeELF32L || type == LLVMBinaryTypeELF32B ) ;
154+ /* bit 1: 0 is 32-bit, 1 is 64-bit */
155+ return obj_data -> target_info . bin_type & 2 ? false : true ;
156156}
157157
158158static bool
159- is_little_endian_binary (LLVMBinaryRef binary )
159+ is_little_endian_binary (const AOTObjectData * obj_data )
160160{
161- LLVMBinaryType type = LLVMBinaryGetType ( binary );
162- return ( type == LLVMBinaryTypeELF32L || type == LLVMBinaryTypeELF64L ) ;
161+ /* bit 0: 0 is little-endian, 1 is big-endian */
162+ return obj_data -> target_info . bin_type & 1 ? false : true ;
163163}
164164
165165static bool
@@ -568,7 +568,7 @@ get_func_section_size(AOTCompData *comp_data, AOTObjectData *obj_data)
568568 /* text offsets + function type indexs */
569569 uint32 size = 0 ;
570570
571- if (is_32bit_binary (obj_data -> binary ))
571+ if (is_32bit_binary (obj_data ))
572572 size = (uint32 )sizeof (uint32 ) * comp_data -> func_count ;
573573 else
574574 size = (uint32 )sizeof (uint64 ) * comp_data -> func_count ;
@@ -852,7 +852,7 @@ get_relocation_section_size(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
852852 return (uint32 )sizeof (uint32 ) + symbol_table_size
853853 + get_relocation_groups_size (relocation_groups ,
854854 relocation_group_count ,
855- is_32bit_binary (obj_data -> binary ));
855+ is_32bit_binary (obj_data ));
856856}
857857
858858static uint32
@@ -1181,7 +1181,7 @@ get_name_section_size(AOTCompData *comp_data)
11811181 return 0 ;
11821182 }
11831183
1184- max_aot_buf_size = 4 * (p_end - p );
1184+ max_aot_buf_size = 4 * (uint32 )( p_end - p );
11851185 if (!(buf = comp_data -> aot_name_section_buf =
11861186 wasm_runtime_malloc (max_aot_buf_size ))) {
11871187 aot_set_last_error ("allocate memory for custom name section failed." );
@@ -1689,7 +1689,7 @@ aot_emit_func_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
16891689 EMIT_U32 (section_size );
16901690
16911691 for (i = 0 ; i < obj_data -> func_count ; i ++ , func ++ ) {
1692- if (is_32bit_binary (obj_data -> binary ))
1692+ if (is_32bit_binary (obj_data ))
16931693 EMIT_U32 (func -> text_offset );
16941694 else
16951695 EMIT_U64 (func -> text_offset );
@@ -1816,7 +1816,7 @@ aot_emit_relocation_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
18161816 /* emit each relocation */
18171817 for (j = 0 ; j < relocation_group -> relocation_count ; j ++ , relocation ++ ) {
18181818 offset = align_uint (offset , 4 );
1819- if (is_32bit_binary (obj_data -> binary )) {
1819+ if (is_32bit_binary (obj_data )) {
18201820 EMIT_U32 (relocation -> relocation_offset );
18211821 EMIT_U32 (relocation -> relocation_addend );
18221822 }
@@ -1883,9 +1883,9 @@ aot_emit_name_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
18831883 /* sub section id + name section size */
18841884 EMIT_U32 (sizeof (uint32 ) * 1 + comp_data -> aot_name_section_size );
18851885 EMIT_U32 (AOT_CUSTOM_SECTION_NAME );
1886- bh_memcpy_s ((uint8 * )(buf + offset ), buf_end - buf ,
1886+ bh_memcpy_s ((uint8 * )(buf + offset ), ( uint32 )( buf_end - buf ) ,
18871887 comp_data -> aot_name_section_buf ,
1888- comp_data -> aot_name_section_size );
1888+ ( uint32 ) comp_data -> aot_name_section_size );
18891889 offset += comp_data -> aot_name_section_size ;
18901890
18911891 * p_offset = offset ;
@@ -2321,8 +2321,8 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
23212321 LLVMRelocationIteratorRef rel_itr ;
23222322 AOTRelocation * relocation = group -> relocations ;
23232323 uint32 size ;
2324- bool is_binary_32bit = is_32bit_binary (obj_data -> binary );
2325- bool is_binary_little_endian = is_little_endian_binary (obj_data -> binary );
2324+ bool is_binary_32bit = is_32bit_binary (obj_data );
2325+ bool is_binary_little_endian = is_little_endian_binary (obj_data );
23262326 bool has_addend = str_starts_with (group -> section_name , ".rela" );
23272327 uint8 * rela_content = NULL ;
23282328
0 commit comments