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?

Jeffrey Hantin
  • 35,734
  • 7
  • 75
  • 94
valentyn
  • 55
  • 4

4 Answers4

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.

devstuff
  • 8,277
  • 1
  • 27
  • 33
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.

Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
  • 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 '08 at 13:07
  • Or include a request on Quality Central asking for a compiler feature that enables to produce **exactly** equal executables. – Fabricio Araujo Dec 04 '08 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.

macropas
  • 3,100
  • 3
  • 22
  • 25
0

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

Peter Miehle
  • 5,984
  • 2
  • 38
  • 55
  • 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 '12 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. – Peter Miehle Aug 31 '12 at 14:09