是否可以反汇编/检查 .Net JITer / ngen 生成的本机代码? (纯粹出于学术目的)
试图回答这个问题 我对 JITer 会执行什么样的优化很感兴趣 - 而不是疯狂地推测,我真的很希望能够亲眼看看到底发生了什么。
到目前为止,我已经:
- 使用 ngen(这个输出可能与 JIT 编译器的输出不同吗?)
- 从 GAC 中复制了本机映像
,但现在我有点卡住了 - 因为据我所知,.Net 程序集采用 可移植可执行文件 格式,但是普通工具我可能会使用反汇编这样一个文件(objdump)只是 barf:
C:\Users\justin\Desktop>objdump -d ConsoleApplication1.ni.exe
objdump: ConsoleApplication1.ni.exe: File format not recognized
以这种方式查看本机图像是否可行?如果做不到这一点,是否有其他方法可以满足我的好奇心? (例如反汇编正在运行的进程中的代码)
Is it possible to disassemble / inspect the native code produced by the .Net JITer / ngen? (for purely academic purposes)
In attempting to answer this question I became intrigued about what sort of optimisations the JITer would perform - rather than speculate wildly I'd really like to be able to see for myself what is really hapenning.
So far I've:
- Installed a native image of my candidate assembly using ngen (is the output of this potentially different from the output of the JIT compiler?)
- Copied the native image out of the GAC
But now I'm a bit stuck - as far as I was aware .Net assemblies are in the portable execuable format, but the normal tools that I might use to disassemble such a file (objdump) just barf:
C:\Users\justin\Desktop>objdump -d ConsoleApplication1.ni.exe
objdump: ConsoleApplication1.ni.exe: File format not recognized
Is it feasible to peek inside a native image in this way? Failing that is there some alternative way that I might be able to satisfy my curiosity? (for example disassembling the code in a running process)
发布评论
评论(1)
我在 Windbg 和 dumpbin< 方面取得了一些成功/a> 过去,当尝试这种事情时。
I've had some success with windbg and dumpbin in the past, when trying this sort of thing.