装配头原始数据的差异 [英] Difference in assembly header raw data

查看:100
本文介绍了装配头原始数据的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VS 2010创建了一个C#.NET控制台应用程序和类库项目,并将其与源代码和已编译的二进制文件(dll和exe)一起签入版本控制存储库。我的同事从版本控制工具中获取了最新的源代码,并编译了源代码以生成二进制文件。作为验收测试的一部分,二进制文件使用超比较进行比较。生成的二进制文件的维度(大小)与版本控制存储库中可用的二进制文件相同。当我们使用超越比较执行十六进制比较时,我们发现我和我的同事生成的二进制文件之间存在很大差异。



调查问题,我使用dumpbin utilty提取了OS头和元数据信息。根据该数据,我们观察到二进制文件的差异是由于时间戳(非常容易理解)和.text头部分下的原始数据。当我们密切监视相同二进制文件的dumpbin时,一些原始数据在不同的内存地址中混杂。



任何人都可以帮助我理解这种行为的原因?



提前感谢。



问候

Sudheendra

解决方案



正在编译相同的C#程序两次保证产生相同的二进制输出?



No.


$ b $嗯,这是一个简单的博客写。



也许更多背景可能有用。



Eric继续解释为什么两次编译相同的源代码不会产生相同的二进制文件的各种原因。除了必须为各种编译器伪像生成唯一名称之外,编译器还会生成每个模块的元数据并将唯一的GUID插入到每个模块的元数据中,从而得出以下结论:C#compiler by design 永远不会生成两次相同的二进制文件



事实上,你的问题听起来几乎与Eric在帖子结束时讨论的情况相同


I had created a C#.NET console application and class library project using VS 2010 and checked-in into the version control repository along with the source code and compiled binaries (dll & exe). My collegue took the latest source code from the version control tool and compiled the source code to generate the binaries. As a part of acceptance test both the binaries are compared using beyond compare. The generated binaries are identical in dimension (size) with the binaries available in the version control repository. When we performed hex compare using beyond compare, then it has been observed that there is a lot differences between the binaries generated by me and my collegue.

To investigate the issue, I extracted the OS header and metadata information using the dumpbin utilty. From that data we observed that difference in the binaries is because of timestamp (quite understandable) and raw data under the .text header section. When we closely monitor the dumpbin of the identical binaries some of the raw data were jumbled across the different memory addresses.

Can anyone help me in understanding the reason for this behaviour?

Thanking in advance.

Regards
Sudheendra

解决方案


Is compiling the same C# program twice guaranteed to produce the same binary output?

No.

Well, that was an easy blog to write.

Maybe some more background might be useful.


Eric goes on to explain the various reasons why compiling the same source code twice won't produce an identical binary file. In addition to having to generate unique names for various compiler artefacts, the compiler generates and inserts a unique GUID into the meta-data of each module, leading to the conclusion that: "the C# compiler by design never produces the same binary twice".

In fact, your question sounds almost identical to the situation that Eric discusses at the end of his post.


这篇关于装配头原始数据的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆