加载时和运行时动态链接的区别 [英] Difference between load-time and run-time dynamic linking

查看:9
本文介绍了加载时和运行时动态链接的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

加载时动态链接和运行时动态链接有什么区别?

What is the difference between Load-time dynamic linking and Run-time dynamic linking?

推荐答案

加载时动态链接

当一个可执行文件在构建时链接到一个 DLL 时,链接器不会插入目标代码,而是插入一个 存根,基本上说这个名称的函数是位于这个 DLL 中.

When an executable is linked to a DLL at build time the linker will not insert object code but rather it insert a stub which basically says a function of this name is located in this DLL.

现在当可执行文件运行时,可执行文件的位将丢失(即函数存根),因此在允许程序运行之前,程序加载器通过将它们替换为DLL 文件的入口点.

Now when the executable is run, bits of the executable will be missing (i.e the function stubs) so before the program is allowed to run the program loader fixes up these missing functions by replacing them with entry points into the DLL files.

只有在所有存根都被替换(即解决)之后,才会允许可执行文件运行.

Only after all the stubs have been replace (i.e resolved) will the executable be allowed to run.

即加载时动态链接.

运行时动态链接

在这种情况下,可执行文件没有链接到任何 DLL 库文件,因此它不会在 dll 中包含任何存根,因此程序加载器在运行可执行文件时没有问题.

In this case the executable was not linked to any DLL library file, so it will not contain any stubs into the dll and as such the program loader has no issue running the executable.

但是从 DLL 内部访问函数的任务留给可执行文件,可以使用 GetProcAddress Windows API 完成.

But the task of getting access to the function from with-in the DLL is left to the executable and can be done using the GetProcAddress Windows API.

那是运行时动态链接.

这篇关于加载时和运行时动态链接的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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