forked from OSchip/llvm-project
COFF: Fix entry point inference bug.
Previously, LLD couldn't find a default entry point if it's defined by a library. llvm-svn: 239982
This commit is contained in:
parent
92b0b02e29
commit
ae36985af7
|
@ -187,6 +187,14 @@ Defined *SymbolTable::find(StringRef Name) {
|
|||
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::findDefaultEntry() {
|
|||
{"wWinMain", "wWinMainCRTStartup"},
|
||||
};
|
||||
for (auto E : Entries) {
|
||||
resolveIfPossible(E[1]);
|
||||
if (find(E[1]))
|
||||
return StringRef(E[1]);
|
||||
if (!find(E[0]))
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue