Fix wamrc endian/bit-width check invalid issue on win32 target (#886)

Use the previous resolved binary type info (obj_data->target_info.bin_type) to
check the endian and bit-width but not the raw binary info, the latter is not
suitable for the check for Win32 object file type.

And fix the symbol comparison issue in resolve_target_sym(), as in Win32, the
symbol name of a function added by LLVMAddFunction() is prefixed by '_',
which leads to invalid result returned by strcmp().
This commit is contained in:
Wenyong Huang
2021-12-14 08:45:48 +08:00
committed by GitHub
parent 2917a0c814
commit bbaf0a3c37
2 changed files with 25 additions and 17 deletions

View File

@ -1689,11 +1689,19 @@ resolve_target_sym(const char *symbol, int32 *p_index)
if (!(target_sym_map = get_target_symbol_map(&num)))
return NULL;
for (i = 0; i < num; i++)
if (!strcmp(target_sym_map[i].symbol_name, symbol)) {
for (i = 0; i < num; i++) {
if (!strcmp(target_sym_map[i].symbol_name, symbol)
#if defined(_WIN32) || defined(_WIN32_)
/* In Win32, the symbol name of function added by
LLVMAddFunction() is prefixed by '_', ignore it */
|| (strlen(symbol) > 1 && symbol[0] == '_'
&& !strcmp(target_sym_map[i].symbol_name, symbol + 1))
#endif
) {
*p_index = (int32)i;
return target_sym_map[i].symbol_addr;
}
}
return NULL;
}