gpt4 book ai didi

c++ - Visual C++ 中的二进制再现性

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:29:35 25 4
gpt4 key购买 nike

有没有办法在 Visual C++ 中强制相同的代码生成相同的二进制文件?关闭 PE 中的时间戳或强制 PE 中的时间戳为某个固定值,换句话说?

最佳答案

它不仅是一个时间戳 - 还有一个用于 PDB 匹配的嵌入式 GUID - 如 John Robbins explains .

除此之外,没有办法强制编译器生成一致的结果,正如 Jim Griesmer explains -

compiler writers are far more interested in generating correctly functioning code and generating it quickly than ensuring that whatever is generated is laid out identically on your hard drive. Due to the numerous and varied methods and implementations for optimizing code, it is always possible that one build ended up with a little more time to do something extra or different than another build did. Thus, the final result could be a different set of bits for what is the same functionality.

因此,保证函数和部分顺序在结果 PE 中的顺序一致。链接中有一个示例。

关于c++ - Visual C++ 中的二进制再现性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1363217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com