比较相同源代码的二进制文件 [英] Compare binary files of same source code

查看:267
本文介绍了比较相同源代码的二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论源代码或程序集号没有变化,只要编译源代码,它都会生成一组新的dll和可执行文件,它们与以前的编译不同.每次源时都会产生不同的校验和 代码已编译,因此无法证明源代码是否发生了更改.我知道microsoft在编译时插入了一些datetime数据,这会导致不同的输出.有一个来自Microsoft的实用工具Dumpbin.exe http://support.microsoft.com/kb/164151/en-gb 可以解决问题,但就我而言,每当使用该问题时,输出都不会告诉已更改的内容,因为它应该告诉我们唯一的变化是日期时间戳.

Whenever source code is compiled it generates new set of dlls and executables which are different from the prvious compilation even though there has been no change in the source code or assembly number. This results in different Checksum everytime the source code is compiled hence no proof that whether the source did change or not. I understand that microsoft inserts some datetime data at the compilation which results in different output. There is a utlity from microsoft called Dumpbin.exe http://support.microsoft.com/kb/164151/en-gb which deals with problem but in my case whenever its been used it the output doesn't tell what has been changed as its supposed to tell if the only change was in datetime stamp.

有没有办法证明两个二进制文件是从相同的源代码产生的.

Is there any way to prove that two binaries were produced from same source code.

还有另一个工具BitDiffer,该工具仅适用于.Net,不适用于C ++.我想要一些适用于C ++的东西.

There is another tool BitDiffer which works only for .Net but not for C++. I want something that works for C++.

推荐答案

如果您仔细地遵循了该页面上的步骤,并且二进制文件满足了该步骤的要求(例如必须是Release版本),那么该过程应该足以告诉您基础图像是否相同.

Provided you follow the procedure carefully on that page, and the binaries satisfy the procedure's requirements (e.g. must be a Release build), that procedure should be enough to tell you whether the underlying images are the same. 

但是,这不能保证它们是从相同的源代码构建的!可能(尽管不太可能)两个略有不同的源代码版本可以编译为相同的目标代码.

This does not guarantee that they were built from the same source code, however!  It is possible (although unlikely) that two slightly different versions of the source code can compile to the same object code.

另请参阅该页面上的注释

See also the note on that page which says

注意:不能保证Visual C ++在连续构建中构建相同的源文件时将生成相同的二进制映像.

NOTE: There is no guarantee that Visual C++ will generate the same binary image when building the same source files on successive builds.

确保两个内部版本具有相同源代码的常用方法是使用版本控制工具(或更普遍地,使用软件配置管理(SCM)工具)来存储和标记与之对应的一组特定的源构建. 要正确执行此操作,您必须确保构建构建所需的一切-可以在完全不同的计算机上复制,包括库,可执行文件和构建脚本.

The usual approach to guaranteeing that two builds have the same source code is by using a Revision Control tool (or more generally, a Software Configuration Management (SCM) tool) to store and label a specific set of sources corresponding to a build.  To do this properly, you have to make sure that everything that goes into constructing a build - including libraries, executables, build scripts can be reproduced on a completely different machine.


这篇关于比较相同源代码的二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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