This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Comparing binaries automatically



> On Dec 19, 2017, at 12:09 PM, Philip Prindeville <philipp_subx@redfish-solutions.com> wrote:
> 
> 
> 
>> On Dec 19, 2017, at 6:06 AM, Simon Richter <Simon.Richter@hogyros.de> wrote:
>> 
>> Hi,
>> 
>> On 19.12.2017 05:48, Philip Prindeville wrote:
>> 
>>> Anyone know of a way to do a “smart” comparison of executables (or relocatable objections, or shared libraries, or…)?
>> 
>> The Debian Reproducible Builds project has a tool called "diffoscope",
>> as well as a few years experience reproducing compilation results, so
>> this may be a good starting point:
>> 
>> https://wiki.debian.org/ReproducibleBuilds
>> 
>> They don't have a good solution for __DATE__ yet though, unless you
>> consider a compiler flag warning about its use a solution.
>> 
>>  Simon
>> 
> 
> 
> Yeah, I’ve seen a variety of approaches to the __DATE__/__TIME__/__TIMESTEMP__ problem, including setting SOURCE_DATE_EPOCH to the mtime of the youngest file in the tarball or the timestamp of the most recent git commit, etc. (although squashing/rebasing commits tends to screw up their timestamp in that the code might be changed/updated but the timestamp remains that of the original commit not the rebased once).
> 
> No perfect solution.
> 
> Will have a look at diffoscope, thanks.
> 
> 
> -Philip
> 


Hi all,

I tried doing the following:

#define __Variant __attribute__((section(“.variant”)))

…

const char __revision[] __Variant = REVISION;		/* defined by CPPFLAGS on command-line */

and then substituting out occurrences (there was just one) of REVISION for __revision, and recompiling.

The tried the following steps:

% mips-openwrt-linux-uclibc-objcopy -R .variant dnssec_test dnssec_test.stripped
% mips-openwrt-linux-uclibc-objdump -D dnssec_test > dnssec_test.lst
% mips-openwrt-linux-uclibc-objdump -D dnssec_test.stripped > dnssec_test.stripped.lst
% diff -u dnssec_test.lst dnssec_test.stripped.lstt > dnssec_test.diff

The result is attached.

The differences in the filenames I expected.  The missing .variant section was of course the desired effect.

But what I don’t get is why the symbol names for the subsequent addresses (00414010, 0041443c, 00414440, 004144f0, and 0000000) ended up disagreeing.

In the future, when comparing two different compiles, I’ll be deleting the .variant section from both of them, so the offsets should be affected similarly, and there won’t be disagreement.

But here on the same file before and after deletion, there was.  It shouldn’t be a problem but it is curious and I’d like to understand it and if possible, find a workaround.

Thanks,

-Philip



Attachment: dnssec_test.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]