[lld] r239982 - COFF: Fix entry point inference bug.
Rui Ueyama
ruiu at google.com
Wed Jun 17 17:40:33 PDT 2015
Author: ruiu
Date: Wed Jun 17 19:40:33 2015
New Revision: 239982
URL: http://llvm.org/viewvc/llvm-project?rev=239982&view=rev
Log:
COFF: Fix entry point inference bug.
Previously, LLD couldn't find a default entry point if it's
defined by a library.
Added:
lld/trunk/test/COFF/entrylib.ll
Modified:
lld/trunk/COFF/SymbolTable.cpp
lld/trunk/COFF/SymbolTable.h
Modified: lld/trunk/COFF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.cpp?rev=239982&r1=239981&r2=239982&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.cpp (original)
+++ lld/trunk/COFF/SymbolTable.cpp Wed Jun 17 19:40:33 2015
@@ -187,6 +187,14 @@ Defined *SymbolTable::find(StringRef Nam
return nullptr;
}
+std::error_code SymbolTable::resolveIfPossible(StringRef Name) {
+ auto It = Symtab.find(Name);
+ if (It != Symtab.end())
+ if (auto *B = dyn_cast<Lazy>(It->second->Body))
+ return addMemberFile(B);
+ return std::error_code();
+}
+
// Windows specific -- Link default entry point name.
ErrorOr<StringRef> SymbolTable::findDefaultEntry() {
// If it's DLL, the rule is easy.
@@ -205,6 +213,7 @@ ErrorOr<StringRef> SymbolTable::findDefa
{"wWinMain", "wWinMainCRTStartup"},
};
for (auto E : Entries) {
+ resolveIfPossible(E[1]);
if (find(E[1]))
return StringRef(E[1]);
if (!find(E[0]))
Modified: lld/trunk/COFF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.h?rev=239982&r1=239981&r2=239982&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.h (original)
+++ lld/trunk/COFF/SymbolTable.h Wed Jun 17 19:40:33 2015
@@ -88,6 +88,7 @@ private:
std::error_code addBitcode(BitcodeFile *File);
std::error_code resolve(SymbolBody *Body);
+ std::error_code resolveIfPossible(StringRef Name);
std::error_code addMemberFile(Lazy *Body);
ErrorOr<ObjectFile *> createLTOObject(llvm::LTOCodeGenerator *CG);
Added: lld/trunk/test/COFF/entrylib.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/entrylib.ll?rev=239982&view=auto
==============================================================================
--- lld/trunk/test/COFF/entrylib.ll (added)
+++ lld/trunk/test/COFF/entrylib.ll Wed Jun 17 19:40:33 2015
@@ -0,0 +1,11 @@
+; RUN: llvm-as -o %t.obj %s
+; RUN: rm -f %t.lib
+; RUN: llvm-ar cru %t.lib %t.obj
+; RUN: lld -flavor link2 /out:%t.exe %t.lib
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+define i32 @mainCRTStartup() {
+ ret i32 0
+}
More information about the llvm-commits
mailing list