[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] libtcc run in process compiled with O2 coredump

From: jee
Subject: [Tinycc-devel] libtcc run in process compiled with O2 coredump
Date: Fri, 19 Oct 2012 23:25:17 +0800

I use libtcc to compile code like this:
libtcc code:
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;
this code's asm is like this:
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!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]