예제 #1
0
CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * RecompPos) :
    m_VAddrEnter(VAddrEnter),
    m_VAddrFirst(VAddrEnter),
    m_VAddrLast(VAddrEnter),
    m_CompiledLocation(RecompPos),
    m_EnterSection(NULL),
    m_Test(1)
{
    CCodeSection * baseSection = new CCodeSection(this, VAddrEnter, 0, false);
    if (baseSection == NULL)
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
    }
    m_Sections.push_back(baseSection);
    baseSection->AddParent(NULL);
    baseSection->m_CompiledLocation = (uint8_t *)-1;
    baseSection->m_Cont.JumpPC = VAddrEnter;
    baseSection->m_Cont.FallThrough = true;
    baseSection->m_Cont.RegSet = baseSection->m_RegEnter;

    m_EnterSection = new CCodeSection(this, VAddrEnter, 1, true);
    if (m_EnterSection == NULL)
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
    }
    baseSection->m_ContinueSection = m_EnterSection;

    m_EnterSection->AddParent(baseSection);
    m_Sections.push_back(m_EnterSection);
    m_SectionMap.insert(SectionMap::value_type(VAddrEnter,m_EnterSection));

    if (g_TransVaddr->VAddrToRealAddr(VAddrEnter,*(reinterpret_cast<void **>(&m_MemLocation[0]))))
    {
        m_MemLocation[1] = m_MemLocation[0] + 1;
        m_MemContents[0] = *m_MemLocation[0];
        m_MemContents[1] = *m_MemLocation[1];
    }
    else
    {
        memset(m_MemLocation,0,sizeof(m_MemLocation));
        memset(m_MemContents,0,sizeof(m_MemContents));
    }
    AnalyseBlock();
}
예제 #2
0
CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * CompiledLocation) :
m_VAddrEnter(VAddrEnter),
m_VAddrFirst(VAddrEnter),
m_VAddrLast(VAddrEnter),
m_CompiledLocation(CompiledLocation),
m_EnterSection(NULL),
m_RecompilerOps(NULL),
m_Test(1)
{
#if defined(__arm__) || defined(_M_ARM)
    // make sure function starts at odd address so that the system knows it is thumb mode
    if (((uint32_t)m_CompiledLocation % 2) == 0)
    {
        m_CompiledLocation+=1;
    }
#endif
#if defined(__i386__) || defined(_M_IX86)
    m_RecompilerOps = new CX86RecompilerOps;
#elif defined(__arm__) || defined(_M_ARM)
    m_RecompilerOps = new CArmRecompilerOps;
#endif
    if (m_RecompilerOps == NULL)
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
        return;
    }
    CCodeSection * baseSection = new CCodeSection(this, VAddrEnter, 0, false);
    if (baseSection == NULL)
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
    }

    m_Sections.push_back(baseSection);
    baseSection->AddParent(NULL);
    baseSection->m_CompiledLocation = (uint8_t *)-1;
    baseSection->m_Cont.JumpPC = VAddrEnter;
    baseSection->m_Cont.FallThrough = true;
    baseSection->m_Cont.RegSet = baseSection->m_RegEnter;

    m_EnterSection = new CCodeSection(this, VAddrEnter, 1, true);
    if (m_EnterSection == NULL)
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
    }
    baseSection->m_ContinueSection = m_EnterSection;
    m_EnterSection->AddParent(baseSection);
    m_Sections.push_back(m_EnterSection);
    m_SectionMap.insert(SectionMap::value_type(VAddrEnter, m_EnterSection));

    if (g_TransVaddr->VAddrToRealAddr(VAddrEnter, *(reinterpret_cast<void **>(&m_MemLocation[0]))))
    {
        m_MemLocation[1] = m_MemLocation[0] + 1;
        m_MemContents[0] = *m_MemLocation[0];
        m_MemContents[1] = *m_MemLocation[1];
    }
    else
    {
        memset(m_MemLocation, 0, sizeof(m_MemLocation));
        memset(m_MemContents, 0, sizeof(m_MemContents));
    }

    AnalyseBlock();
}