Re: gcc binary comparison help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Caleb Cittadino wrote:

> I need to compare two binaries build by gcc to determine if they have
> the same contents.  My issue is that I can't build (using the same
> build target) two of the same binary.  I believe this is because a
> timestamp or something of the kind is being put in.  Is there another
> way I can check these contents against each other without the extra
> info?

Well, you didn't mention anything about what platform and object format
you're using so I don't think you're going to get any definitive
answers.

But the gcc bootstrap machinery itself uses "cmp --ignore-initial=16 a
b" to compare the outputs of each stage so that the timestamp in the
object file isn't compared.  (Except for portability it detects whether
to use that form or "cmp a b 16 16" or whether to fall-back to "tail
+16c", see the ACX_PROG_CMP_IGNORE_INITIAL macro in config/acx.m4.)

If that doesn't work, you may have to check the docs for whatever file
format you're using to see where it keeps the timestamp, if any.  And
this assumes that your source code does not contain any macros such as
__TIME__ or __DATE__ or whatever that might embed a unique value in a
string.  If that's the case then I guess you'd have to resort to keeping
the preprocessed source around and only compiling that.

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux