Difference between load-time and run-time dynamic linking

前端 未结 3 448
长情又很酷
长情又很酷 2020-12-16 04:07

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

3条回答
  •  抹茶落季
    2020-12-16 05:00

    Load-time Dynamic Linking

    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.

    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.

    That is load time dynamic linking.

    Run-time Dynamic Linking

    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.

    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.

    That is run time dynamic linking.

提交回复
热议问题