running x86 program _on_ llvm

梦想与她 提交于 2019-12-04 11:24:18

问题


Is it possible to use llvm to run x86 programs? I.e. I want to use llvm as an x86 simulator to run x86 programs and then instrument the x86 program.

Thanks!


回答1:


I think you are looking for LibCPU.

It has an x86 frontend (well, actually only 8086 at the moment, and that is not even complete, but they're working on it), and since it is built on top of LLVM, it obviously also has an x86 backend, thus making it possible to run x86-on-x86 but passing it through LLVM's optimization, instrumentation and analysis stages.




回答2:


Also, there was a project to use LLVM in qemu. It is also a way of running x86 code via LLVM.

http://code.google.com/p/llvm-qemu/

It was GSoC project, but there is a code in svn and author have results:

regular qemu     llvm-qemu rle,dse,simple regalloc   llvm-qemu full opts
4m35.349s             5m39.697s                        13m50.697s

llvm-qemu twice-thrice slower than qemu, but it works.




回答3:


I don't know libCPU, but there is libx86, which does something very similar; if running on an 32-bit x86 processor (but not in 64-bit mode), it runs a virtual 8086 process, if running elsewhere, it tries to emulate the 8086 in software. Pretty cool. Documentation is relatively scarce though.

http://www.codon.org.uk/~mjg59/libx86/



来源:https://stackoverflow.com/questions/2649519/running-x86-program-on-llvm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!