1

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:

  1. Installed a native image of my candidate assembly using ngen (is the output of this potentially different from the output of the JIT compiler?)
  2. 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)

Community
  • 1
  • 1
Justin
  • 84,773
  • 49
  • 224
  • 367
  • 1
    I got some useful techniques when I asked [Is there a way to see the native code produced by theJITter for given C# / CIL?](http://stackoverflow.com/questions/1945719/is-there-a-way-to-see-the-native-code-produced-by-thejitter-for-given-c-cil) – AakashM Aug 25 '11 at 14:44
  • Can't you take a look with windbg, or dumpbin? – Tim Barrass Aug 25 '11 at 14:51
  • @AakashM Very useful and probably more reliable than inspecing native images! – Justin Aug 25 '11 at 15:13
  • No problem :) Actually, I might even add that as an answer :) – Tim Barrass Aug 25 '11 at 19:13

1 Answers1

1

I've had some success with windbg and dumpbin in the past, when trying this sort of thing.

Tim Barrass
  • 4,813
  • 2
  • 29
  • 55