.NET程序集和DLL重订基期 [英] .NET assemblies and DLL rebasing

查看:211
本文介绍了.NET程序集和DLL重订基期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这篇文章重订基期是没有必要的.NET程序集由于在code JIT编译。文章说:

According to this article rebasing is not necessary for .NET assemblies due to JIT compilation of the code. The article states:

JI​​T编译的code没有一个重订基期问题,因为在运行时所产生的地址的基础上,其中code被放置在内存中。此外,MSIL很少受基址射门自MSIL引用是基于标记的,而不是基于地址的。因此,当JIT编译器的情况下,该系统是弹性的,以基地址冲突。

不过,我已经注意到VS2008分配默认0​​x0400000基址所有程序集(项目属性>构建 - >高级),如果我做了 listdlls的/ R 我处理我所有的.NET程序集,其实每默认重订。

However, I have noticed that VS2008 assigns the default 0x0400000 base address to all assemblies (project properties > build > advanced) and if I do a listdlls /r for my process all my .NET assemblies are in fact rebased per default.

如果我给你地址自己,不垫底就完成了。

If I assign addresses myself, no rebasing is done.

我的问题是:什么是重订在这种情况下,为什么

My question is: What is rebased in this case and why?

编辑:我要补充一点,我说的不是NGen'ed组件

I should add that I am not talking about NGen'ed assemblies.

推荐答案

CLR加载机制使用调用LoadLibrary幕后,所以这就是你观察:2组件不能在同一地址加载。现在,人们常常意味着,当他们试图变基一个dll是为了避免PERF。打的固定窗口,如绝对地址和放大器;函数调用需要重新定位与加载的基地址。因为MSIL code为按需当你加载CLR不存在这个问题(不知道在应用程序中,这就是那些固定窗口的第二部分,我将需要阅读了这条静态数据)请致电管理code函数。该MSIL然后得到即时编译并放置在堆上,一个不同的正常对象堆我相信,以相同的方式CLR分配并规定了在应用程序中的新对象。

CLR Loading mechanism uses LoadLibrary behind the scenes, so this is what you observe: 2 assemblies can't be loaded at the same address. Now what people often mean when they try to rebase a dll is to avoid the perf. hit of fix-ups, e.g. absolute addresses & function calls need to be "relocated" with the loaded base-address. CLR does not have this problem (not sure about static data in the application, which is the second part of those fix-ups, I would need to read up on this), because MSIL code is loaded on-demand when you call a function in the managed code. The MSIL then gets jitted and placed on the heap, a different one from normal object heap I believe, in the same manner CLR allocates and lays out new objects in your application.

这篇关于.NET程序集和DLL重订基期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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