Is there kind of runtime C++ assembler library around? [closed]

一世执手 提交于 2019-11-27 18:19:38

问题


For my small hobby project I need to emit machine code from C++ program in runtime. I have base address 0xDEADBEEF and want to write something like this:

Assembler a((void*)0xDEADBEEF);
a.Emit() << 
  Push(Reg::Eax) <<
  Push(Reg::Ebx) <<
  Jmp(0xFEFEFEFE);

Inline assembler isn't my choice because generated machine code is dependent of the program state.

Does anybody know any existing library for doing this? If no, would it be a good idea to develop one from scratch and make it open source? (I mean, will anybody ever use this library if it existed?)


回答1:


You could use Nicolas Capen's softwire. Its really not supported any more as he now works on a similar product at Transgaming called SoftAsm. Still it kinda does what you want.

Edit June 2014: - It appears the sourceforge link above has been removed but it appears to be available under an LGPL license here.




回答2:


Check out Asmjit. It seems to be the thing you're looking for.




回答3:


This might be a overkill, because it supports many platforms, has its own intermediate language, does optimizations, etc, but the http://llvm.org/ seems to be a god try.



来源:https://stackoverflow.com/questions/2787002/is-there-kind-of-runtime-c-assembler-library-around

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