[PATCH] D43964: Report an error if you try to link against .dll instead of .lib.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 1 12:51:39 PST 2018
ruiu created this revision.
ruiu added a reviewer: rnk.
It is a usage error to feed a .dll file instead of a .dll to COFF linker.
Previously, lld failed with a mysterious error message. Now we reject
it at the driver.
Fixes https://bugs.llvm.org/show_bug.cgi?id=36440
https://reviews.llvm.org/D43964
Files:
lld/COFF/Driver.cpp
lld/test/COFF/driver.test
Index: lld/test/COFF/driver.test
===================================================================
--- lld/test/COFF/driver.test
+++ lld/test/COFF/driver.test
@@ -4,3 +4,8 @@
# RUN: lld-link --version | FileCheck -check-prefix=VERSION %s
VERSION: {{LLD [0-9]+\.[0-9]+}}
+
+# RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj
+# RUN: lld-link /out:%t.dll /dll %t.obj
+# RUN: not lld-link /out:%t.exe %t.dll 2>&1 | FileCheck -check-prefix=BADFILE %s
+BADFILE: unknown file type
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -132,7 +132,6 @@
case file_magic::windows_resource:
Resources.push_back(MBRef);
break;
-
case file_magic::archive:
if (WholeArchive) {
std::unique_ptr<Archive> File =
@@ -145,18 +144,19 @@
}
Symtab->addFile(make<ArchiveFile>(MBRef));
break;
-
case file_magic::bitcode:
Symtab->addFile(make<BitcodeFile>(MBRef));
break;
-
+ case file_magic::coff_object:
+ case file_magic::coff_import_library:
+ Symtab->addFile(make<ObjFile>(MBRef));
+ break;
case file_magic::coff_cl_gl_object:
error(MBRef.getBufferIdentifier() + ": is not a native COFF file. "
"Recompile without /GL");
break;
-
default:
- Symtab->addFile(make<ObjFile>(MBRef));
+ error(MBRef.getBufferIdentifier() + ": unknown file type");
break;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43964.136589.patch
Type: text/x-patch
Size: 1436 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180301/fa4e6e4b/attachment.bin>
More information about the llvm-commits
mailing list