使用 Delphi 6 编译两次并在二进制文件上获得相同的校验和
出于二进制/源代码验证的目的,我希望能够在同一台计算机上相隔两周进行两次编译,并使二进制文件相同,从而通过一些校验和测试。
到目前为止,我发现时间戳很可能会被编译器写入二进制文件中。我可以通过根据这篇 msdn 文章对 dumpbin /rawdata 结果进行比较来解决这个问题。
http://support.microsoft.com/kb/164151
但是,dumpbin 结果仍然不同例如,大约有十几个地方,差异似乎仍然是某种时间戳(从 A1 73 更改为 C4 76)。
我假设这是delphi编译器放入代码/数据部分的时间戳,但我找不到发生这种情况的位置或如何将其关闭。摆弄各种编译器/链接器选项并没有改变这种行为。
任何帮助将不胜感激。
For the purposes of binary / source code verification, i'd like to be able to make two compiles on the same computer 2 weeks apart and have the binaries be identical and thus pass some checksum test.
So far I've found that most likely the timestamp will be written by the compiler into the binary. I can work around this by doing the compare on the dumpbin /rawdata results per this msdn article.
http://support.microsoft.com/kb/164151
However the dumpbin results still differ in a about a dozen places and the difference still appears to be some kind of timestamp (changing from A1 73 to C4 76) for example.
I assume this is the timestamp that the delphi compiler is putting into the code/data sections but i can't find where this is happening or how to turn it off. Fiddling with the various compiler/linker options has not changed this behavior.
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
几年前我们研究过这个问题,我记得答案很简单,Borland/Codegear/Embarcadero 的人不同意编译器应该在给定完全相同的输入的情况下产生完全相同的输出(假设当前日期时间不能被视为输入)。
这令人失望,但考虑到 Delphi 的主要版本已经过时了,它可能不会改变。
We researched this question a few years ago, and as I recall the answer was simply that the people at Borland/Codegear/Embarcadero do not subscribe to the notion that the compiler should produce exactly the same output given exactly the same input (given that the current date-time is not acceptable to consider as input).
This is disappointing, but given that Delphi is upmteen major versions old, it probably will not change.
根据您在问题中的评论,我认为您正在寻找该问题的答案:
一种方法是采用自动构建过程:
您必须确保您的源代码实际使用该验证标记(例如通过在“关于”框中显示或类似的内容)。
我使用 FinalBuilder 来自动化这样的构建过程。
——杰罗恩
Based on your comment in the question, I think you are searching for the answer to this question:
One way is to have an automated built process that:
You must make sure that your sourcecode actually uses that verification tag (for instance by showing in an about box, or something similar).
I use FinalBuilder to automate build processes like this.
--jeroen
不幸的是我还没有听说过这个问题的任何答案。
这不仅仅是时间戳,而且在某些地方,内存之外的几个字节的随机垃圾最终会出现在结果中。
Unfortunately I haven't heard of any answer to this problem.
It's not just timestamps but there are places where a few bytes of random garbage out of memory ends up in the result.