使用 Delphi 6 编译两次并在二进制文件上获得相同的校验和

发布于 2024-08-12 15:40:57 字数 454 浏览 7 评论 0原文

出于二进制/源代码验证的目的,我希望能够在同一台计算机上相隔两周进行两次编译,并使二进制文件相同,从而通过一些校验和测试。

到目前为止,我发现时间戳很可能会被编译器写入二进制文件中。我可以通过根据这篇 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

此岸叶落 2024-08-19 15:40:57

几年前我们研究过这个问题,我记得答案很简单,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.

巴黎盛开的樱花 2024-08-19 15:40:57

根据您在问题中的评论,我认为您正在寻找该问题的答案:

如何验证某个二进制文件是否由一组特定的源文件创建

一种方法是采用自动构建过程:

  1. 在源代码中插入唯一的验证标记(可能与 GUID 字符串或其他内容一样简单)包含文件)
  2. 使用该验证标记编译二进制文件
  3. 将生成的二进制文件和源代码打包在交付目录树中

您必须确保您的源代码实际使用该验证标记(例如通过在“关于”框中显示或类似的内容)。

我使用 FinalBuilder 来自动化这样的构建过程。

——杰罗恩

Based on your comment in the question, I think you are searching for the answer to this question:

How can I verify that a certain binary is created by a certain set of source files

One way is to have an automated built process that:

  1. Inserts a unique verififcation tag in the source code (might be as simple as a GUID string or something else in an include file)
  2. Compiles the binaries using that verification tag
  3. Packs the resulting binary and source code in a delivery directory tree

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

烟燃烟灭 2024-08-19 15:40:57

不幸的是我还没有听说过这个问题的任何答案。

这不仅仅是时间戳,而且在某些地方,内存之外的几个字节的随机垃圾最终会出现在结果中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文