简体   繁体   中英

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)?

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. 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.

You can use the tool bsdiff , and it's companion bspatch, for doing efficient diffs and patches of binary files.

If you want to get even smaller patches, you can take a look at Courgette , from Google Chrome. It's built on bsdiff, but they provide even more efficient diffs of executables by actually disassembling them before doing the diff. It's not distributed as a separate project, but you can get it from the Chromium source repository (how to check out the code ).

There is also the xdelta tool, that has been around longer than bsdiff. According to the author of bsdiff, it is considerably less efficient; 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.

diff will tell you if the binary files are different:

diff bin1 bin2
Binary files bin1 and bin2 differ

If you want the difference, use 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 --verbose Output byte numbers and values of all differing bytes. 

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

You can use diff :

diff old_file new_file

You can also use md5 but you have to compare results than. It could be used also for checking sum of downloaded file if md5 check sum is available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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