简体   繁体   English

如何计算linux中两个二进制文件(即两个可执行文件)之间的差异

[英]how to compute differences between two binaries (i.e., two executables) in linux

In Linux is there any way to compute the differences between two binaries (ie, two executables)? 在Linux中有没有办法计算两个二进制文件(即两个可执行文件)之间的差异?

Let me be more specific: I want to know how to compute the delta (delta difference) between two versions of an executable or application or software in Linux. 让我更具体一点:我想知道如何计算Linux中两个版本的可执行文件或应用程序或软件之间的增量(delta差异)。 For example if I have to download and install only the updated part (the delta difference between the latest version and the old version) of an existing application or binary how do I do that in Linux. 例如,如果我必须仅下载并安装现有应用程序或二进制文件的更新部分(最新版本和旧版本之间的差异),我该如何在Linux中执行此操作。

You can use the tool bsdiff , and it's companion bspatch, for doing efficient diffs and patches of binary files. 你可以使用工具bsdiff和它的伴随bspatch来做有效的差异和二进制文件的补丁。

If you want to get even smaller patches, you can take a look at Courgette , from Google Chrome. 如果您想获得更小的补丁,可以查看Google Chrome中的Courgette It's built on bsdiff, but they provide even more efficient diffs of executables by actually disassembling them before doing the diff. 它建立在bsdiff之上,但它们通过在进行差异之前实际拆解它们来提供更高效的可执行文件差异。 It's not distributed as a separate project, but you can get it from the Chromium source repository (how to check out the code ). 它不是作为单独的项目分发的,但您可以从Chromium源存储库 (如何检查代码 )中获取它。

There is also the xdelta tool, that has been around longer than bsdiff. 还有xdelta工具,比bsdiff更长。 According to the author of bsdiff, it is considerably less efficient; 根据bsdiff的作者,效率相当低; patches come out much bigger. 补丁更大。 It has the advantage that it supports the standard VCDIFF format ( RFC 3284 ), which is supported by several other tools as well, so if you need to work with such other tools, it would be more useful. 它的优点是它支持标准的VCDIFF格式( RFC 3284 ),它也受到其他几个工具的支持,所以如果你需要使用其他工具,它会更有用。

diff will tell you if the binary files are different: diff会告诉你二进制文件是否不同:

diff bin1 bin2
Binary files bin1 and bin2 differ

If you want the difference, use cmp : 如果你想要差异,请使用cmp

cmp -l bin1 bin2 
  25  20 320
  26   4   3
  41 270 160
 209   4 264
 210   7   6

The -l option prints the byte number and the difference: -l选项打印字节数和差异:

 -l --verbose Output byte numbers and values of all differing bytes. 

尝试使用cksum - 表明它们是相同的

You can use diff : 你可以使用diff

diff old_file new_file

You can also use md5 but you have to compare results than. 您也可以使用md5,但必须比较结果。 It could be used also for checking sum of downloaded file if md5 check sum is available. 如果md5校验和可用,它也可以用于检查下载文件的总和。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM