2

Building the same project (without any changes) produces binary different exe-files: some small regions of them are different. Empty project, version information (and auto-increment on every build) is turned off.

Why it happens? And is it possible to make delphi produce binary equal files for the same projects?

4 Answers 4

15

The various structures in the PE executable file format used by Windows include timestamps that are set by the compiler and linker.

It is possible to post-process the file to reset these values to a defined constant (I wrote a tool to do exactly this for a secure product that needed exact hash values), but this should only be done on ready-to-ship executables, as some debuggers rely on the timestamps for source lookup, etc.

2

Try changing the problem into "How do I avoid compiling if there are no changes to the source", might be easier to deal with.

2
  • What if we have no executable module at all but we want get it equal to existing (somewhere) which corresponds particular revision of projects.
    – valentyn
    Nov 27, 2008 at 13:07
  • Or include a request on Quality Central asking for a compiler feature that enables to produce exactly equal executables. Dec 4, 2008 at 18:03
1

I suspect compiler insert to *.exe encoded time, special ordinal numbers (for versioning) and maybe other things :) It's impossible to force Delphi to produce equal binary output.

0

it may be, that some actual time-stamps are compiled into the exe-file.

2
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
    – Emile
    Aug 31, 2012 at 12:44
  • November 27th 2008. Sorry thence I was not so familiar with SO, and now I do not go thru my olde posts and actualise them. But I am still sure, that my answer answers part of the Asker's question, why twice compiling produces different binaries. f.e. I generate a version.h file with #define VERSION and timestamp as first compile step and use that define in debug output. Aug 31, 2012 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.