What is the best way to compare if two binaries (C++) are equivalent in Linux while ignoring metadata?

Viewed 190

I am trying to check which binaries differ in a directory in order to create a patch replacing the old binary. I have access to the source code and the repository (GIT). When I compare the two binaries generated from the exact same source code using diff or cmp the binaries are reported to be different. I assume this is due to metadata or other data that is compiled into the code but is irrelevant to how the binaries behave.

Ideally, I would like to compare the binaries while ignoring any "extra" data. If this is not possible then I would like to compile the binaries while stripping any "extra" data so that the same source code generates the same exact binaries. A lot of the binaries have cross dependencies where one binary is used by another binary and so if one binary changes the other one must be replaced as well.

I am trying to generate a patch that replaces old binaries with new ones and any other binaries that need to replaced as a result of the changes in the new binary.

0 Answers
Related