[PATCH] D37710: [LLD] [MinGW] Pass the undecorated entry point name to the COFF linker
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 11 13:59:23 PDT 2017
mstorsjo created this revision.
On i386, the --entry parameter to GNU ld is supposed to be a decorated symbol name, while it is an undecorated name in link.exe.
https://reviews.llvm.org/D37710
Files:
MinGW/Driver.cpp
test/MinGW/driver.s
Index: test/MinGW/driver.s
===================================================================
--- test/MinGW/driver.s
+++ test/MinGW/driver.s
@@ -54,6 +54,9 @@
# CHECK-IMPLIB: Symbol: __imp_exportfn3
# CHECK-IMPLIB: Symbol: exportfn3
+# RUN: ld.lld -shared -m i386pe -e _DllMainCRTStartup at 12 %t.obj -o %t.dll -### | FileCheck %s -check-prefix CHECK-I386-ENTRY
+# CHECK-I386-ENTRY: lld-link -entry:DllMainCRTStartup at 12
+
.global main
.text
main:
Index: MinGW/Driver.cpp
===================================================================
--- MinGW/Driver.cpp
+++ MinGW/Driver.cpp
@@ -127,8 +127,13 @@
Add("lld-link");
- if (auto *A = Args.getLastArg(OPT_entry))
- Add("-entry:" + StringRef(A->getValue()));
+ if (auto *A = Args.getLastArg(OPT_entry)) {
+ if (Args.getLastArgValue(OPT_m) == "i386pe" && A->getValue()[0] == '_')
+ Add("-entry:" + StringRef(A->getValue()).substr(1));
+ else
+ Add("-entry:" + StringRef(A->getValue()));
+ }
+
if (auto *A = Args.getLastArg(OPT_subs))
Add("-subsystem:" + StringRef(A->getValue()));
if (auto *A = Args.getLastArg(OPT_outlib))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37710.114683.patch
Type: text/x-patch
Size: 1118 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170911/f34e9b8f/attachment.bin>
More information about the llvm-commits
mailing list