[PATCH] D40553: [LLD] [COFF] Don't export symbols that have corresponding __imp_ symbols

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 14:04:02 PST 2017


mstorsjo added inline comments.


================
Comment at: COFF/MinGW.cpp:103-109
+  // Don't export anything that looks like an import symbol (which also can be
+  // a manually defined data symbol with such a name).
+  if (Sym->getName().startswith("__imp_"))
+    return false;
+  // If a corresponding __imp_ symbol exists and is defined, don't export it.
+  if (Symtab->find(("__imp_" + Sym->getName()).str()))
+    return false;
----------------
ruiu wrote:
> nit: add a blank line before each comment.
Ok, will do.


================
Comment at: COFF/MinGW.cpp:105-108
+  if (Sym->getName().startswith("__imp_"))
+    return false;
+  // If a corresponding __imp_ symbol exists and is defined, don't export it.
+  if (Symtab->find(("__imp_" + Sym->getName()).str()))
----------------
ruiu wrote:
> Don't you have to handle the i386 name mangling which is ___imp_ (triple underscores)?
No, the `__imp_` prefix is added before the actual symbol name. The function `foo` which for cdecl gets mangled into `_foo` has the corresponding `__imp__foo` (while it'd be `__imp_foo` for x86_64), so here it works out automatically.


https://reviews.llvm.org/D40553





More information about the llvm-commits mailing list