none
请教一下,doc文档说DLL在隐式链接情况下,system modifies the executable code 。这个modifies到底modifies了什么呢? RRS feed

  • 问题

  • 来源

    https://docs.microsoft.com/zh-cn/cpp/build/linking-an-executable-to-a-dll?view=vs-2019#linking-explicitly

    该doc文档开头的 Implicit Linking 这一节的第五段。

    该小节内容全文复制如下:

    Implicit Linking

    Implicit linking occurs when an application's code calls an exported DLL function. When the source code for the calling executable is compiled or assembled, the DLL function call generates an external function reference in the object code. To resolve this external reference, the application must link with the import library (.lib file) provided by the maker of the DLL.

    The import library only contains code to load the DLL and to implement calls to functions in the DLL. Finding an external function in an import library informs the linker that the code for that function is in a DLL. To resolve external references to DLLs, the linker simply adds information to the executable file that tells the system where to find the DLL code when the process starts up.

    When the system starts a program that contains dynamically linked references, it uses the information in the program's executable file to locate the required DLLs. If it can't locate the DLL, the system terminates the process, and displays a dialog box that reports the error. Otherwise, the system maps the DLL modules into the process address space.

    If any of the DLLs has an entry-point function for initialization and termination code such as DllMain, the operating system calls the function. One of the parameters passed to the entry-point function specifies a code that indicates the DLL is attaching to the process. If the entry-point function doesn't return TRUE, the system terminates the process and reports the error.

    Finally, the system modifies the executable code of the process to provide starting addresses for the DLL functions.

    Like the rest of a program's code, the loader maps DLL code into the address space of the process when the process starts up. The operating system loads it into memory only when needed. As a result, the PRELOAD and LOADONCALL code attributes used by .def files to control loading in previous versions of Windows no longer have meaning.

    ————————

    文档也没说到底做了什么动作。。。

    2020年10月19日 13:12