'C++ __imp_ prefix

Although I see it mentioned everywhere that the __imp_ prefix is prepended to symbols for exported functions within a DLL (with the __imp_ version resolving directly into the IAT), I have never found any documentation on the matter, I have simply been relying on the words of others.

Is it every defined that symbols export two versions of themselves in any official documentation? Or did people simply figure this out by disassembling PE files produced by common linkers?

Relatedly, is there a reason why linkers have decided to create two versions of the same symbol? Why not just have the non-__imp_ version be the one which resolves into the IAT of the executable, while still making the code which references the symbol within the DLL use dllimport?

Also, I have seen a wide range of "imp" prefixes used, including _imp_, _imp__, __imp__, and of course __imp_. Which one is technically "correct"? (or are they different depending on the linker?).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source