コード例 #1
0
ファイル: jitcore_tcc.py プロジェクト: Junraa/miasm
    def gen_c_code(self, label, irblocks):
        """
        Return the C code corresponding to the @irblocks
        @label: asm_label of the block to jit
        @irblocks: list of irblocks
        """
        f_name = self.label2fname(label)
        f_declaration = 'int %s(block_id * BlockDst, JitCpu* jitcpu)' % f_name
        out = irblocs2C(self.ir_arch, self.resolver, label, irblocks,
                        gen_exception_code=True,
                        log_mn=self.log_mn,
                        log_regs=self.log_regs)
        out = [f_declaration + '{'] + out + ['}\n']
        c_code = out

        return gen_C_source(self.ir_arch, c_code)
コード例 #2
0
ファイル: jitcore_tcc.py プロジェクト: 13572293130/miasm
    def jitirblocs(self, label, irblocs):
        f_name = "bloc_%s" % label.name
        f_declaration = 'void %s(block_id * BlockDst, vm_cpu_t* vmcpu, vm_mngr_t* vm_mngr)' % f_name
        out = irblocs2C(self.ir_arch, self.resolver, label, irblocs,
                        gen_exception_code=True,
                        log_mn=self.log_mn,
                        log_regs=self.log_regs)
        out = [f_declaration + '{'] + out + ['}\n']
        c_code = out

        func_code = gen_C_source(self.ir_arch, c_code)

        # open('tmp_%.4d.c'%self.jitcount, "w").write(func_code)
        self.jitcount += 1
        tcc_state, mcode = jit_tcc_compil(f_name, func_code)
        self.tcc_states.append(tcc_state)
        jcode = jit_tcc_code(mcode)
        self.lbl2jitbloc[label.offset] = mcode
        self.addr2obj[label.offset] = jcode
        self.addr2objref[label.offset] = objref(jcode)
コード例 #3
0
ファイル: jitcore_tcc.py プロジェクト: luwangg/miasm
    def jitirblocs(self, label, irblocs):
        f_name = "bloc_%s" % label.name
        f_declaration = 'void %s(block_id * BlockDst, vm_cpu_t* vmcpu, vm_mngr_t* vm_mngr)' % f_name
        out = irblocs2C(self.ir_arch,
                        self.resolver,
                        label,
                        irblocs,
                        gen_exception_code=True,
                        log_mn=self.log_mn,
                        log_regs=self.log_regs)
        out = [f_declaration + '{'] + out + ['}\n']
        c_code = out

        func_code = gen_C_source(self.ir_arch, c_code)

        # open('tmp_%.4d.c'%self.jitcount, "w").write(func_code)
        self.jitcount += 1
        tcc_state, mcode = jit_tcc_compil(f_name, func_code)
        jcode = jit_tcc_code(mcode)
        self.lbl2jitbloc[label.offset] = mcode
        self.tcc_states[label.offset] = tcc_state
        self.addr2obj[label.offset] = jcode
        self.addr2objref[label.offset] = objref(jcode)