Esempio n. 1
0
int
main() {
    const RegisterDictionary *regdict = RegisterDictionary::dictionary_i386();
    SymbolicSemantics::RiscOperatorsPtr ops = SymbolicSemantics::RiscOperators::instance(regdict);
    RegisterStateGenericPtr rstate = RegisterStateGeneric::promote(ops->currentState()->registerState());
    SValuePtr x;
    Formatter fmt;
    fmt.set_line_prefix("    ");

    // Write all 32 bits of a register
    std::cout <<"write reg@0+32\n";
    RegisterDescriptor r_0_32(x86_regclass_gpr, 0, 0, 32);
    rstate->writeRegister(r_0_32, ops->undefined_(32), ops.get());
    rstate->print(std::cout, fmt);

    // Write low-order 16 bits of a register
    std::cout <<"\nwrite reg@0+16\n";
    RegisterDescriptor r_0_16(x86_regclass_gpr, 0, 0, 16);
    rstate->writeRegister(r_0_16, ops->undefined_(16), ops.get());
    rstate->print(std::cout, fmt);

    // Read bits 8-31. Bits [8-15] are from one register and [16-31] are from another
    std::cout <<"\nread reg@8+24\n";
    RegisterDescriptor r_8_24(x86_regclass_gpr, 0, 8, 24);
    x = rstate->readRegister(r_8_24, ops->undefined_(r_8_24.get_nbits()), ops.get());
    std::cout <<"  got " <<*x <<"\n";
    rstate->print(std::cout, fmt);
}
NoOperation::NoOperation(Disassembler *disassembler) {
    normalizer_ = StateNormalizer::instance();

    if (disassembler) {
        const RegisterDictionary *registerDictionary = disassembler->get_registers();
        ASSERT_not_null(registerDictionary);
        size_t addrWidth = disassembler->instructionPointerRegister().get_nbits();

        SMTSolver *solver = NULL;
        SymbolicSemantics::RiscOperatorsPtr ops = SymbolicSemantics::RiscOperators::instance(registerDictionary, solver);
        ops->computingDefiners(SymbolicSemantics::TRACK_NO_DEFINERS);
        ops->computingMemoryWriters(SymbolicSemantics::TRACK_LATEST_WRITER); // necessary to erase non-written memory

        BaseSemantics::MemoryCellListPtr mstate = BaseSemantics::MemoryCellList::promote(ops->currentState()->memoryState());
        ASSERT_not_null(mstate);
        mstate->occlusionsErased(true);

        cpu_ = disassembler->dispatcher()->create(ops, addrWidth, registerDictionary);
    }
}