且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows下的确定性构建

更新时间:2023-02-06 19:07:06

目前我们有一个构建系统,它确保所有新构建都在恒定长度的路径上(builds / 001,builds / 002等),从而避免PE布局。在构建之后,工具将比较忽略相关PE字段和具有已知表面变化的其他位置的旧的和新的二进制。它还运行一些简单的启发式方法来检测动态可忽略的更改。以下是要忽略的事项的完整列表:

Currently we have build system that makes sure all new builds are on the path of constant length (builds/001, builds/002, etc), thus avoiding shifts in the PE layout. After build a tool compares old and new binaries ignoring relevant PE fields and other locations with known superficial changes. It also runs some simple heuristics to detect dynamic ignorable changes. Here is full list of things to ignore:


  • PE时间戳和校验和

  • 数字签名目录项

  • 导出表格时间戳

  • 调试器时间戳

  • PDB签名,年龄和文件路径

  • 资源时间戳

  • 在VS_VERSION_INFO资源中的所有文件/产品版本

  • 数字签名部分

  • 嵌入式类型库的MIDL虚拟存根(包含时间戳字符串)

  • __ FILE__,__DATE__和__TIME__宏用作文字字符串(可以是宽字符或窄字符) >
  • PE timestamp and checksum
  • Digital signature directory entry
  • Export table timestamp
  • Debugger section timestamp
  • PDB signature, age and file path
  • Resources timestamp
  • All file/product versions in VS_VERSION_INFO resource
  • Digital signature section
  • MIDL vanity stub for embedded type libraries (contains timestamp string)
  • __FILE__, __DATE__ and __TIME__ macros when they are used as literal strings (can be wide or narrow char)

一旦在一个时间链接器将使一些PE部分更大,而不抛出任何不对齐。看起来它移动区边界内填充 - 它是零,无论如何,但因为它,我会得到与1字节差异的二进制。

Once in a while linker would make some PE sections bigger without throwing anything else out of alignment. Looks like it moves section boundary inside the padding -- it is zeros all around anyway, but because of it I'll get binaries with 1 byte difference.

UPDATE:我们最近在 GitHub 。请参阅文档中的比较部分。

UPDATE: we recently opensourced the tool on GitHub. See Compare section in documentation.