PE 格式
.exe, .dll 都属于 PE 格式。
CIL
中间语言不是 C# 的特权,C++/C 等编译型语言都可以生成中间语言。
CIL 与 PE 格式
.dll, .exe 中包含的并不全是机器码,它既可以包含机器码,也可包含中间语言。 下面这句话出自 Mono:
The CLI is able to host C++ compiled code on all supported platforms as long as the compiled code only contains CIL instructions and not a mix of CIL and native code.Microsoft Managed C++ and C++/CLI compilers produce mixed-mode assemblies by default.
http://www.mono-project.com/docs/about-mono/languages/cplusplus/
可以看出 PE 格式是一种混合模式,而且 C++ 也可以生成中间语言。关于 PE 格式的描述可以看下面这篇文档,从里面也可以看出 PE 文件既可以包含 native code, 也可以包含 IL:
Common Language Infrastructure (CLI).[ECMA-335]
关键词
native code: 机器码
IL: 中间语言(个人理解:中间语言和汇编代码比较像,但是 MSIL 是基于栈的)。
JIT: 实时编译
AOT: 提前编译
IL 汇编/反汇编工具
ildasm: 将 PE 文件转成可读 IL 文件
ilasm: 将 IL 文件转成 PE 文件
相关阅读