[PATCH] D44292: [LLD] [COFF, MinGW] Implement the GNU ld flag --kill-at

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 14 11:55:18 PDT 2018


mstorsjo added a comment.

In https://reviews.llvm.org/D44292#1037301, @rnk wrote:

> lgtm
>
> I'm curious, what is the use case for this feature? The binutils docs describe exactly what it does but not why one would want to use it.


In mingw tools, there's much less of the automatic stdcall mangling/matching that makes it sane in link.exe.  If you do `void __declspec(dllexport) __stdcall PluginEntry(...) {` in mingw, the object file export directive will be `-export:PluginEntry at X`, and you'll end up exporting it with the literal `@X` suffix in the dll - which `--kill-at` fixes.



================
Comment at: COFF/DriverUtils.cpp:586
+// Convert stdcall/fastcall style symbols into unsuffixed symbols,
+// with or without a leading underscore.
+static StringRef killAt(StringRef Sym, bool Prefix) {
----------------
ruiu wrote:
> Please also say that this is MinGW-specific.
Ok, will do.


================
Comment at: COFF/DriverUtils.cpp:592
+  Sym = Sym.substr(0, Sym.find('@', 1));
+  if (Sym.startswith("@")) {
+    // For fastcall, remove the leading @ and replace it with an
----------------
ruiu wrote:
> You can flip the condition to return early.
Oh, indeed. (I had an else clause here at some point, but it turned out to be unnecessary.)


================
Comment at: test/COFF/def-export-stdcall.s:75
+# MINGW-KILL-AT-IMPLIB-NEXT: __imp__stdcall
+# MINGW-KILL-AT-IMPLIB-NEXT: _stdcall
+
----------------
rnk wrote:
> We might as well test vectorcall for completeness.
GCC doesn't support vectorcall, so there's no reference on how it should behave with that.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D44292





More information about the llvm-commits mailing list