diff options
author | Rui Ueyama <ruiu@google.com> | 2015-06-28 22:35:15 +0300 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2015-06-28 22:35:15 +0300 |
commit | 95925fd1abee62ab12293d3b7e255a5308e6d7af (patch) | |
tree | bfdd8fa7554e95b43be812bf07107d355ca5b04c /lld/COFF | |
parent | 5126186b32f16cf7caccd740cb12fbc8ff04ddf9 (diff) |
COFF: Support /force flag.
This option is to ignore remaining undefined symbols and force
the linker to create an output file anyways.
The existing code assumes that there's no undefined symbol after
reportRemainingUndefines(). That assumption is legitimate.
I also don't want to mess up the existing code for this minor feature.
In order to keep it as is, remaining undefined symbols are replaced
with dummy defined symbols.
llvm-svn: 240913
Diffstat (limited to 'lld/COFF')
-rw-r--r-- | lld/COFF/Config.h | 1 | ||||
-rw-r--r-- | lld/COFF/Driver.cpp | 4 | ||||
-rw-r--r-- | lld/COFF/SymbolTable.cpp | 6 |
3 files changed, 11 insertions, 0 deletions
diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h index 823385228c53..801478149697 100644 --- a/lld/COFF/Config.h +++ b/lld/COFF/Config.h @@ -46,6 +46,7 @@ struct Configuration { std::string OutputFile; bool DoGC = true; bool Relocatable = true; + bool Force = false; // Symbols in this set are considered as live by the garbage collector. std::set<StringRef> GCRoots; diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 634b63c425b8..d2dbd96a8fe2 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -265,6 +265,10 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) { if (Args.hasArg(OPT_verbose)) Config->Verbose = true; + // Handle /force or /force:unresolved + if (Args.hasArg(OPT_force) || Args.hasArg(OPT_force_unresolved)) + Config->Force = true; + // Handle /entry if (auto *Arg = Args.getLastArg(OPT_entry)) { Config->EntryName = Arg->getValue(); diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp index 75157805d074..aae6b22b4a09 100644 --- a/lld/COFF/SymbolTable.cpp +++ b/lld/COFF/SymbolTable.cpp @@ -92,6 +92,12 @@ bool SymbolTable::reportRemainingUndefines() { } } llvm::errs() << "undefined symbol: " << Name << "\n"; + // Remaining undefined symbols are not fatal if /force is specified. + // They are replaced with dummy defined symbols. + if (Config->Force) { + Sym->Body = new (Alloc) DefinedAbsolute(Name, 0); + continue; + } Ret = true; } return Ret; |