0

I've seen several conflicting descriptions of how to do this around the google results, and haven't been able to get any of them to work.

My problem is basically this: where I call ExecutionEngine::getPointerToFunction (with an llvm::Function*), I'd like to instead get the pretty-printed x86 assembly that would be produced for this function.

Anybody?

[ETA: I'm using LLVM 3.3. The descriptions I've found seem to be for earlier versions of LLVM.]

4

1 回答 1

0

事实证明,您可以使用 ExecutionEngine::RegisterJITEventListener 将事件侦听器添加到 JIT ExecutionEngine。如果您提供该类的实例,则可以在为您生成机器代码时调用回调,并且您将获得指向机器代码及其长度的指针。有了这个,你可以调用 llvm::sys::disassembleBuffer 来获取机器码缓冲区的描述。

但是,如果 LLVM 是使用该支持编译的,则 llvm::sys::disassembleBuffer 函数只是遵循 udis 库。由于我的 LLVM 构建没有设置此标志并且我无法重建它,我将直接研究使用 udis 库:

https://github.com/vmt/udis86

于 2013-08-26T15:16:05.113 回答