forked from OSchip/llvm-project
COFF: Improve undefined symbol diagnostics.
We now report the names of any files containing undefined symbol references. Differential Revision: http://reviews.llvm.org/D10982 llvm-svn: 241612
This commit is contained in:
parent
4bc34b1515
commit
f5339ec035
|
@ -123,7 +123,7 @@ bool SymbolTable::queueEmpty() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SymbolTable::reportRemainingUndefines(bool Resolve) {
|
bool SymbolTable::reportRemainingUndefines(bool Resolve) {
|
||||||
bool Ret = false;
|
llvm::SmallPtrSet<SymbolBody *, 8> Undefs;
|
||||||
for (auto &I : Symtab) {
|
for (auto &I : Symtab) {
|
||||||
Symbol *Sym = I.second;
|
Symbol *Sym = I.second;
|
||||||
auto *Undef = dyn_cast<Undefined>(Sym->Body);
|
auto *Undef = dyn_cast<Undefined>(Sym->Body);
|
||||||
|
@ -150,17 +150,24 @@ bool SymbolTable::reportRemainingUndefines(bool Resolve) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
llvm::errs() << "undefined symbol: " << Name << "\n";
|
|
||||||
// Remaining undefined symbols are not fatal if /force is specified.
|
// Remaining undefined symbols are not fatal if /force is specified.
|
||||||
// They are replaced with dummy defined symbols.
|
// They are replaced with dummy defined symbols.
|
||||||
if (Config->Force) {
|
if (Config->Force && Resolve)
|
||||||
if (Resolve)
|
|
||||||
Sym->Body = new (Alloc) DefinedAbsolute(Name, 0);
|
Sym->Body = new (Alloc) DefinedAbsolute(Name, 0);
|
||||||
continue;
|
Undefs.insert(Sym->Body);
|
||||||
}
|
}
|
||||||
Ret = true;
|
if (Undefs.empty())
|
||||||
}
|
return false;
|
||||||
return Ret;
|
for (Undefined *U : Config->GCRoot)
|
||||||
|
if (Undefs.count(U->repl()))
|
||||||
|
llvm::errs() << "<root>: undefined symbol: " << U->getName() << "\n";
|
||||||
|
for (std::unique_ptr<InputFile> &File : Files)
|
||||||
|
if (!isa<ArchiveFile>(File.get()))
|
||||||
|
for (SymbolBody *Sym : File->getSymbols())
|
||||||
|
if (Undefs.count(Sym->repl()))
|
||||||
|
llvm::errs() << File->getShortName() << ": undefined symbol: "
|
||||||
|
<< Sym->getName() << "\n";
|
||||||
|
return !Config->Force;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolTable::addLazy(Lazy *New, std::vector<Symbol *> *Accum) {
|
void SymbolTable::addLazy(Lazy *New, std::vector<Symbol *> *Accum) {
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
# RUN: not lld -flavor link2 /out:%t.exe %t.obj > %t.log 2>&1
|
# RUN: not lld -flavor link2 /out:%t.exe %t.obj > %t.log 2>&1
|
||||||
# RUN: FileCheck -check-prefix=WWINMAIN %s < %t.log
|
# RUN: FileCheck -check-prefix=WWINMAIN %s < %t.log
|
||||||
|
|
||||||
# MAIN: undefined symbol: mainCRTStartup
|
# MAIN: <root>: undefined symbol: mainCRTStartup
|
||||||
# WMAIN: undefined symbol: wmainCRTStartup
|
# WMAIN: <root>: undefined symbol: wmainCRTStartup
|
||||||
# WINMAIN: undefined symbol: WinMainCRTStartup
|
# WINMAIN: <root>: undefined symbol: WinMainCRTStartup
|
||||||
# WWINMAIN: undefined symbol: wWinMainCRTStartup
|
# WWINMAIN: <root>: undefined symbol: wWinMainCRTStartup
|
||||||
|
|
||||||
---
|
---
|
||||||
header:
|
header:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# RUN: lld -flavor link2 /out:%t.exe /entry:main %t.obj /force >& %t.log
|
# RUN: lld -flavor link2 /out:%t.exe /entry:main %t.obj /force >& %t.log
|
||||||
# RUN: FileCheck %s < %t.log
|
# RUN: FileCheck %s < %t.log
|
||||||
|
|
||||||
# CHECK: undefined symbol: foo
|
# CHECK: .obj: undefined symbol: foo
|
||||||
|
|
||||||
---
|
---
|
||||||
header:
|
header:
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
CHECK1: hello64.obj: {{[Nn]}}o such file or directory
|
CHECK1: hello64.obj: {{[Nn]}}o such file or directory
|
||||||
CHECK2: hello64: {{[Nn]}}o such file or directory
|
CHECK2: hello64: {{[Nn]}}o such file or directory
|
||||||
CHECK3: undefined symbol: MessageBoxA
|
CHECK3: hello64.obj: undefined symbol: MessageBoxA
|
||||||
|
|
||||||
# RUN: lld -flavor link2 /libpath:%T /out:%t.exe /entry:main \
|
# RUN: lld -flavor link2 /libpath:%T /out:%t.exe /entry:main \
|
||||||
# RUN: /subsystem:console hello64.obj /defaultlib:std64.lib
|
# RUN: /subsystem:console hello64.obj /defaultlib:std64.lib
|
||||||
|
|
Loading…
Reference in New Issue