当使用 make 在不同时间编译时,什么可能会导致二进制文件略有不同?
我使用 make 实用程序编译了代码并获取了二进制文件。
我再次编译了代码,并在 makefile 中进行了一些更改(在某些点插入了 -j
),并且二进制文件略有不同。这种差异是通过“超越比较”来报告的。为了进一步检查,我在没有更改 makefile 的情况下再次编译了代码,发现二进制文件仍然不同。
为什么在不同时间编译的相同代码会导致二进制文件(大小和内容)略有不同?应该如何检查我所做的更改是否合法并且二进制文件在逻辑上是否相同?
请向我询问任何进一步的解释。
I compiled my code using the make utility and got the binaries.
I compiled the code again with a few changes in makefile (-j
inserted at some points) and got a slight difference in the binaries. The difference was reported by "beyond compare". To further check in, I compiled the code again without my changes in makefile and found that the binaries are still differing.
Why is it happening that the same code compiled at different times is resulting into slightly different (in size and content) binaries? How should if check if the changes i have made are legitimate and the binaries are the same logically?
Do ask me for any further explanation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你还没有说你正在构建什么(C、C++ 等),但如果它是一个时间戳,我不会感到惊讶。
您可以找出正在构建的二进制类型的格式(这取决于您的操作系统),并查看在正在更改的位置存在时间戳是否有意义。
在一个很小的示例程序上执行此操作可能是最简单的,该程序将生成一个非常小的二进制文件,以便更容易地弄清楚所有内容的含义。
You haven't said what you're building (C, C++ etc) but I wouldn't be surprised if it's a timestamp.
You could find out the format for the binary type you're building (which will depend on your operating system) and see whether it makes sense for there to be a timestamp in the place which is changing.
It's probably easiest to do this on a tiny sample program which will produce a very small binary, to make it easier to work out what everything means.
ELF 对象文件包含编译时的时间戳。因此,每次编译(在 Linux 或 Solaris 上)时,您都可以期待不同的目标文件。您可能也会在其他目标文件系统中发现同样的情况。
ELF object files contain a timestamp for when they are compiled. Thus, you can expect a different object file each time you compile (on Linux or Solaris). You may find the same with other systems of object files too.