Why isn't it possible* to "re-link" a native shared library (DLL) i开发者_Go百科nto an executable file, as if they had been statically linked? Is the DLL missing any required information?
*Note: Or is it actually posible? If it is, please let me know, but through searches I've come to the conclustion that it's not possible.
It isn't directly possible.
When an EXE loads a DLL (via LoadLibrary
) there's a lot of work done by the DLL loader to patch adresses. You can't just combine a DLL as is with an exe, because its adresses are wrong if it's not dynamically loaded.
On the other hand, a LIB is statically linked: no loading involved, no adress fixing, everything works without further job when you launch the program.
What is possible to do is to convert a DLL and EXE back to OBJ and link them together statically.
精彩评论