Operating System - HP-UX
1819792 Members
3087 Online
109607 Solutions
New Discussion юеВ

Diff between two binary files

 
shivakumara
Occasional Advisor

Diff between two binary files

Hi,
I have got 2 binary files, which compiled with the same source file built at different time. If I do diff b/n these two binaries it will show as difference is there. But actually there is no diff. Can I have any command/workaround to get diff if it is there.
5 REPLIES 5
RAC_1
Honored Contributor

Re: Diff between two binary files

Were same options used to compile those files??
diff is for text files.

cksum on both files may help.
else, strings binary1 and strings binary2 and then compare.
man strings for details.
There is no substitute to HARDWORK
H.Merijn Brand (procura
Honored Contributor

Re: Diff between two binary files

binary diff is 'cmp', but that is byte-by-byte

If these are executables, you can check if there is a diff between the 'nm file' output of each

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
A. Clay Stephenson
Acclaimed Contributor

Re: Diff between two binary files

This is rather pointless because even absolutely identical source code compiled with exactly the same options and linked with the same libraries will still produce different cksums because there is a timestamp embedded in the file header. I'm not talking about the timestamps associated with the file's metadata (ie that in the inode) but rather a timestamp actually written in the executable. Man a.out for details. You should also be very careful about using diff on non-text data because that can easily cause an exception in the code and crash diff depending upon the flavor or version of UNIX.
If it ain't broke, I can fix that.
shivakumara
Occasional Advisor

Re: Diff between two binary files

Hi clay,
I agree with your answer, But I still want to remove that time stamp and wanted to get diff. Can you please suggest me how can I go about this?
Muthukumar_5
Honored Contributor

Re: Diff between two binary files

what is your binary file type?

Check it as,

# file
if it is PA-RISC format then,

# odump -all binary > /tmp/binary.odump
# odump -all binary1 > /tmp/binary1.odump
# diff /tmp/binary.odump /tmp/binary1.odump

I am getting difference on compilation time header and binary name difference only.

You can check for,

# strings binary.strings
# strings binary1.strings
# diff binary.strings binary1.strings

For ELF format files use elfdump utility.

hth.
Easy to suggest when don't know about the problem!