typedef int (*tw_type_CLog2Svr__Write_53)(unsigned int val_0, char val_1, void* val_2, void* val_3);
tw_type_CLog2Svr__Write_53 g_tw_type_CLog2Svr__Write_53;
int tw_CLog2Svr__Write_53(unsigned int val_0, char val_1, void* val_2, void* val_3){
......
int val=
g_tw_type_CLog2Svr__Write_53(val_0, val_1, val_2, val_3);
......
return val;
}
0x00007ffff5645980: mov 0x5af(%rip),%r11 # 0x7ffff5645f36
0x00007ffff5645987: mov (%r11),%r11
0x00007ffff564598a: callq *%r11
when the code come to 0x00007ffff564598a, it's codedump with SIGSEGV.
the ASM CODE 0x5af is wrong!
1.when i change the tcc code from
tw_type_CLog2Svr__Write_53 g_tw_type_CLog2Svr__Write_53;
to !!!static!!! tw_type_CLog2Svr__Write.........
the SIGSEGV disappear。
2.when i round up the tcc_relocate addr to 16, the SIGSEGV disappear。
like this:
int iRet = tcc_relocate(m_tcc, NULL);
m_mem = malloc(iRet + 32);
void *round_up = (void*)(((size_t)m_mem + 0xf) & ~0xf);
iRet = tcc_relocate(m_tcc, round_up)
AND,my c code is compiled with O2!