目标代码上的语言痕迹
是否可以查看目标代码并判断最初使用哪种语言来生成它?或者该语言是否在目标代码上留下了痕迹或印记?各种语言的编译器是否针对给定的 ISA 使用固定格式来开发目标代码?
Is it possible to look at an object code and tell which language has been used originally to produce it? or does the language leaves a trace or a stamp on the object code ? do the compilers of various languages use a fixed format for a given ISA to develop the object code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有通用的算法,但在实践中通常是可能的。通常,您可以只查看应用程序所依赖的库 - 如果 Windows 应用程序依赖于 例如,msvcrt.dll,那么它很有可能是用 Visual C++ 编译的 C 或 C++ 程序。有时编译器会在
.data
部分留下证据痕迹。以下是我在十六进制编辑器中打开类似“Hello, World!”的 Haskell 二进制文件(使用 GHC 编译)时看到的内容:这是 GCC 的“版权声明”的样子:
受过训练的眼睛甚至可以识别编译器版本通过查看反汇编(每个编译器优化代码的方式略有不同,并且有自己的实现怪癖)。如果您需要自动化此操作,我建议查看机器学习技术。
There is no general algorithm, but in practice it is often possible. Usually you can just look at the libraries that the application depends on - if a Windows application depends on msvcrt.dll, for example, then there's a high chance that it's a C or C++ program compiled with Visual C++. Sometimes a compiler leaves traces of evidence in the
.data
section. Here is what I see when opening a "Hello, World!"-like Haskell binary (compiled with GHC) in a hex editor:Here's what GCC's "copyright notice" looks like:
A trained eye can even recognize compiler version by looking at disassembly (every compiler optimizes code slightly differently and has its own implementation quirks). If you need to automate this, I suggest looking at machine learning techniques.
没有。 x86 就是 x86——一旦采用这种格式,就找不到原始语言的痕迹。
Nope. x86 is x86- once it's in that format, there's no trace of the original language.