11

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

"JIT-compiled code does not have a rebasing problem since the addresses are generated at run time based on where the code is placed in memory. Also, MSIL is rarely affected by base address misses since MSIL references are token-based, rather than address-based. Thus when the JIT compiler is used, the system is resilient to base address collisions."

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?

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

4

2 に答える 2

3

CLR 読み込みメカニズムは舞台裏で LoadLibrary を使用するため、次のようになります。2 つのアセンブリを同じアドレスに読み込むことはできません。dll をリベースしようとするとき、人々がしばしば意味することは、パフォーマンスを回避することです。修正のヒット、たとえば絶対アドレスと関数呼び出しは、ロードされたベースアドレスで「再配置」する必要があります。関数を呼び出すと MSIL コードがオンデマンドで読み込まれるため、CLR にはこの問題はありません (これらの修正の 2 番目の部分であるアプリケーションの静的データについては不明です。これについて調べる必要があります)。マネージド コードで。次に、MSIL がジットされてヒープに配置されます。これは、CLR がアプリケーションで新しいオブジェクトを割り当ててレイアウトするのと同じ方法で、通常のオブジェクト ヒープとは異なると思います。

于 2008-12-09T13:24:32.280 に答える
1

どのOSを実行していますか?vista 以降では、DLL をロードするアドレス空間をランダム化する ASLR が導入されたことを知っています。これはシステム dll で発生しますが、.net については不明です。調査する必要があるかもしれません。

于 2008-12-09T13:12:08.123 に答える