确定从二进制源语言吗? [英] Determine source language from a binary?

查看:135
本文介绍了确定从二进制源语言吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<我一个href=\"http://stackoverflow.com/questions/1703088/what-is-the-state-of-non-objective-c-programming-for-iphone/1703160#1703160\">responded大约在非Objective-C的语言为iPhone开发的另一个问题,我做了断言,使用,比如C#编写的iPhone将罢工苹果评论家错了。我主要是谈论问题的ObjC和C#库之间不同的UI元素,而是一个评论者提出一个有趣的问题,导致我这个问题:

I responded to another question about developing for the iPhone in non-Objective-C languages, and I made the assertion that using, say, C# to write for the iPhone would strike an Apple reviewer wrong. I was speaking largely about UI elements differing between the ObjC and C# libraries in question, but a commenter made an interesting point, leading me to this question:

是否有可能确定一个程序编写语言,单从它的二进制?如果有这样的方法,它们是什么?

Is it possible to determine the language a program is written in, solely from its binary? If there are such methods, what are they?

假设为这个问题的目的:

Let's assume for the purposes of the question:


  • 从交互的角度看(控制台的行为,任何GUI外观等)两者是相同的。

  • 这表现不语的可靠指标(不比较,比如说,Java来C)。

  • 那你没有你和语言之间的相互preTER什么 - 只是原始二进制可执行文件

奖励积分,如果你语言无关越好。

Bonus points if you're language-agnostic as possible.

推荐答案

我不是一个编译器黑客(有一天,我希望如此),但我想,你也许能找到一个二进制文件将表明蛛丝马迹什么编译器生成它和一些使用的编译器的选项,如指定的优化的水平

I'm not a compiler hacker (someday, I hope), but I figure that you may be able to find telltale signs in a binary file that would indicate what compiler generated it and some of the compiler options used, such as the level of optimization specified.

严格地说,但是,你要问是不可能的。这可能是有人坐了下来,笔和纸,并制定出相应的,他们希望编写程序二进制codeS,然后键入的东西出一个十六进制编辑器。基本上,他们会用汇编语言编程,而不汇编工具。同样的,你可能永远无法告诉肯定的本地文件是否是写在直汇编或c与内联汇编。

Strictly speaking, however, what you're asking is impossible. It could be that somebody sat down with a pen and paper and worked out the binary codes corresponding to the program that they wanted to write, and then typed that stuff out in a hex editor. Basically, they'd be programming in assembly without the assembler tool. Similarly, you may never be able to tell with certainty whether a native binary was written in straight assembler or in C with inline assembly.

对于虚拟机环境,如JVM和.NET,你应该能够通过字节codeS中的二进制可执行文件来识别虚拟机,我期望的那样。然而,你可能无法告诉来源是什么措辞,如C#与Visual Basic中,除非有特定的编译器怪癖提示你。

As for virtual machine environments such as JVM and .NET, you should be able to identify the VM by the byte codes in the binary executable, I would expect. However you may not be able to tell what the source language was, such as C# versus Visual Basic, unless there are particular compiler quirks that tip you off.

这篇关于确定从二进制源语言吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆