예제 #1
0
static InstTransResult doMOVSrm(NativeModulePtr natM, BasicBlock *& block, InstPtr ip, MCInst &inst) {
    InstTransResult ret;
    Function *F = block->getParent();
    // MOV from memory to XMM register will set the unused poriton
    // of the XMM register to 0s.
    // Just set the whole thing to zero, and let the subsequent
    // write take care of the rest
    R_WRITE<128>(block, OP(0).getReg(), CONST_V<128>(block, 0));

    if( ip->has_external_ref()) {
        Value *addrInt = getValueForExternal<width>(F->getParent(), ip, block);
        TASSERT(addrInt != NULL, "Could not get address for external");
        R_WRITE<width>(block, OP(0).getReg(), addrInt);
        return ContinueBlock;
    }
    else if( ip->is_data_offset() ) {
        ret = doRMMov<width>(ip, block, 
                GLOBAL( block, natM, inst, ip, 1 ),
                OP(0) );
    } else {
        ret = doRMMov<width>(ip, block, ADDR(1), OP(0));
    }
    return ret ;

}
예제 #2
0
static InstTransResult translate_MOVoa (NativeModulePtr natM, BasicBlock *& block, InstPtr ip, MCInst &inst) {
    InstTransResult ret;
    Function *F = block->getParent();
    // loading functions only available if its a 32-bit offset
    if( ip->has_external_ref() && width == 32) {
        Value *addrInt = getValueForExternal<32>(F->getParent(), ip, block);
        TASSERT(addrInt != 0, "Could not get external data reference");
        R_WRITE<width>(block, X86::EAX, addrInt);
        return ContinueBlock;
        //ret = doRMMov<32>(ip, block, addrInt, MCOperand::CreateReg(X86::EAX)) ;
    }
    else if( ip->has_call_tgt() && width == 32 ) {
        Value *callback_fn = makeCallbackForLocalFunction(
                block->getParent()->getParent(), 
                ip->get_call_tgt(0)
            );
        Value *addrInt = new PtrToIntInst(
            callback_fn, llvm::Type::getInt32Ty(block->getContext()), "", block);
        ret = doRMMov<32>(ip, block, addrInt, MCOperand::CreateReg(X86::EAX)) ;
    }
    else if( ip->is_data_offset() ) {
        ret = doRMMov<width>(ip, block, 
                GLOBAL_DATA_OFFSET(block, natM, ip), 
                MCOperand::CreateReg(X86::EAX) ); 
    } else { 
        Value *addrv = CONST_V<width>(block, OP(0).getImm());
        ret = doRMMov<width>(ip, block, addrv, MCOperand::CreateReg(X86::EAX)) ;
    }
    return ret ; 
}
예제 #3
0
static InstTransResult translate_MOV32mr(NativeModulePtr natM, BasicBlock *& block, InstPtr ip, MCInst &inst) 
{
    InstTransResult ret;
    Function *F = block->getParent();
    if( ip->has_external_ref()) {
        Value *addrInt = getValueForExternal<32>(F->getParent(), ip, block);
        TASSERT(addrInt != NULL, "Could not get address for external");
        return doMRMov<32>(ip, block, addrInt, OP(5) );
    }
    else if( ip->is_data_offset() ) {
        ret = doMRMov<32>(ip, block, GLOBAL( block, natM, inst, ip, 0), OP(5) );
    } else { 
        ret = doMRMov<32>(ip, block, ADDR(0), OP(5)) ; 
    }
    return ret ; 
}
예제 #4
0
static InstTransResult translate_LEA64r(NativeModulePtr natM, BasicBlock *&block, InstPtr ip, MCInst &inst) {
    InstTransResult ret;
    Function *F = block->getParent();
    if( ip->has_call_tgt() ) {
        Value *callback_fn = archMakeCallbackForLocalFunction(
                block->getParent()->getParent(), 
                ip->get_call_tgt(0));
        Value *addrInt = new PtrToIntInst(
            callback_fn, llvm::Type::getInt64Ty(block->getContext()), "", block);
        ret = doLeaV<64>(block, OP(0), addrInt);
    } else if(ip->has_external_ref()){
    	Value *addrInt = getValueForExternal<64>(F->getParent(), ip, block);
    	ret = doLeaV<64>(block, OP(0), addrInt);
    }
    else if( ip->is_data_offset() ) {
        ret = doLea<64>(ip, block, STD_GLOBAL_OP(1), OP(0));
    } else { 
        ret = doLea<64>(ip, block, ADDR(1), OP(0));
    }
    return ret;
}