Windows imported DLL function calls in C++ and Rust

In case #2 the compiler knows the function comes from a DLL and uses the mechanism used to call dynamically linked functions.

In case #1 and #3 the function could also be defined in a static library and so it has to emit a generic function call that resolves to a function in the import library that then uses the mechanism to do tail calls to dynamically linked function.

It looks like the Windows linker, object and relocation formats don't support changing the call instruction at link time (which I guess is because it would require to add extra NOPs or have a section split after the call).

The comment should probably be fixed to make this clearer.

2 Likes