COFF: Handle undefined symbols starting with __imp_ in a special way.
authorRui Ueyama <ruiu@google.com>
Thu, 25 Jun 2015 02:21:44 +0000 (02:21 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 25 Jun 2015 02:21:44 +0000 (02:21 +0000)
commitd766653534e0cff702e42a43b44d3057b6094fea
treeafa10a5a8d2020c5bb0ffb31e06fe8c053e8d825
parent7a1372ce34b8dd44ffa52dd1fbc613863eb26771
COFF: Handle undefined symbols starting with __imp_ in a special way.

MSVC linker is able to link an object file created from the following code.
Note that __imp_hello is not defined anywhere.

  void hello() { printf("Hello\n"); }
  extern void (*__imp_hello)();
  int main() { __imp_hello(); }

Function symbols exported from DLLs are automatically mangled by appending
__imp_ prefix, so they have two names (original one and with the prefix).
This "feature" seems to simulate that behavior even for non-DLL symbols.

This is in my opnion very odd feature. Even MSVC linker warns if you use this.
I'm adding that anyway for the sake of compatibiltiy.

llvm-svn: 240620
lld/COFF/SymbolTable.cpp
lld/test/COFF/locally-imported.test [new file with mode: 0644]