<html dir=""><head><style id="axi-htmleditor-style" type="text/css">p { margin: 0px; }</style></head><body style="font-size: 10pt; font-family: Arial; background-image: none; background-repeat: repeat; background-attachment: fixed;">​import llvmlite.binding as llvm<br>import pyvex<br><br>CODE = b"\x55\x48\x8b\x05\xb8\x13\x00\x00"<br>mehran = -100<br><br>#llvm.initialize()<br>#llvm.initialize_native_target()<br>#llvm.initialize_native_asmprinter()<br><br>module = ll.Module()<br>func_ty = ll.FunctionType(ll.VoidType(), [])<br>func = ll.Function(module, func_ty, name='read_instructions')<br><br>bb_entry = func.append_basic_block('entry')<br>irbuilder = ll.IRBuilder(bb_entry)<br><br>irsb = pyvex.block.IRSB(CODE, 0x400400, archinfo.ArchAMD64())<br><br>for stmt in irsb.statements:<br><br>    if isinstance(stmt, pyvex.IRStmt.Store):<br>       result =  irbuilder.store_reg(ll.Constant(ll.IntType(64), stmt.data), ll.IntType(64), stmt.addr)<br>       irbuilde.ret(result)<br><br>print("****************LLVM***********************")<br>print(module)<br><br>#Execute generated code.<br>"""<br># initialize the LLVM machine<br># These are all required (apparently)<br>llvm.initialize()<br>llvm.initialize_native_target()<br>llvm.initialize_native_asmprinter()<br><br># Create engine and attach the generated module<br># Create a target machine representing the host<br>target = llvm.Target.from_default_triple()<br>target_machine = target.create_target_machine()<br># And an execution engine with an empty backing module<br>backing_mod = llvm.parse_assembly("")<br>engine = llvm.create_mcjit_compiler(backing_mod, target_machine)<br><br># Parse our generated module<br>mod = llvm.parse_assembly( str( module ) )<br>mod.verify()<br># Now add the module and make sure it is ready for execution<br>engine.add_module(mod)<br>engine.finalize_object()<br><br>func = engine.get_function_address('read_instructions')<br><br><div>Actually, I want this code to be compiled and executed and print out the output from:<br>       result =  irbuilder.store_reg(ll.Constant(ll.IntType(64), stmt.data), ll.IntType(64), stmt.addr)<br></div>Who knows how can I add lines for getting output for it?<br></body></html><pre>
-- 
This email was Anti Virus checked by  Security Gateway.</pre>