[PATCH] D50598: LLD COFF: Add support for /force:multiple option
Thomas Roughton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 10 15:37:49 PDT 2018
troughton updated this revision to Diff 164760.
troughton marked 2 inline comments as done.
troughton added a comment.
Specify `std::string` over `auto` and change `message` to `Msg`.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D50598
Files:
COFF/Config.h
COFF/Driver.cpp
COFF/Options.td
COFF/SymbolTable.cpp
Index: COFF/SymbolTable.cpp
===================================================================
--- COFF/SymbolTable.cpp
+++ COFF/SymbolTable.cpp
@@ -60,7 +60,7 @@
}
static void errorOrWarn(const Twine &S) {
- if (Config->Force)
+ if (Config->ForceUnresolved)
warn(S);
else
error(S);
@@ -237,7 +237,7 @@
// Remaining undefined symbols are not fatal if /force is specified.
// They are replaced with dummy defined symbols.
- if (Config->Force)
+ if (Config->ForceUnresolved)
replaceSymbol<DefinedAbsolute>(Sym, Name, 0);
Undefs.insert(Sym);
}
@@ -326,8 +326,14 @@
}
void SymbolTable::reportDuplicate(Symbol *Existing, InputFile *NewFile) {
- error("duplicate symbol: " + toString(*Existing) + " in " +
- toString(Existing->getFile()) + " and in " + toString(NewFile));
+ std::string Msg = "duplicate symbol: " + toString(*Existing) +
+ " in " + toString(Existing->getFile()) +
+ " and in " + toString(NewFile);
+
+ if (Config->ForceMultiple)
+ warn(message);
+ else
+ error(message);
}
Symbol *SymbolTable::addAbsolute(StringRef N, COFFSymbolRef Sym) {
Index: COFF/Options.td
===================================================================
--- COFF/Options.td
+++ COFF/Options.td
@@ -99,8 +99,11 @@
def wholearchive_flag : F<"wholearchive">;
def force : F<"force">,
+ HelpText<"Allow undefined and multiply defined symbols when creating executables">;
+def force_unresolved : F<"force:unresolved">,
HelpText<"Allow undefined symbols when creating executables">;
-def force_unresolved : F<"force:unresolved">;
+def force_multiple : F<"force:multiple">,
+ HelpText<"Allow multiply defined symbols when creating executables">;
defm WX : B<"WX", "Treat warnings as errors", "Don't treat warnings as errors">;
defm allowbind : B<"allowbind", "Enable DLL binding (default)",
Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -888,8 +888,12 @@
// Handle /force or /force:unresolved
if (Args.hasArg(OPT_force, OPT_force_unresolved))
- Config->Force = true;
+ Config->ForceUnresolved = true;
+ // Handle /force or /force:multiple
+ if (Args.hasArg(OPT_force, OPT_force_multiple))
+ Config->ForceMultiple = true;
+
// Handle /debug
if (Args.hasArg(OPT_debug, OPT_debug_dwarf, OPT_debug_ghash)) {
Config->Debug = true;
Index: COFF/Config.h
===================================================================
--- COFF/Config.h
+++ COFF/Config.h
@@ -94,7 +94,8 @@
bool DoICF = true;
bool TailMerge;
bool Relocatable = true;
- bool Force = false;
+ bool ForceMultiple = false;
+ bool ForceUnresolved = false;
bool Debug = false;
bool DebugDwarf = false;
bool DebugGHashes = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50598.164760.patch
Type: text/x-patch
Size: 2849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180910/399051ba/attachment.bin>
More information about the llvm-commits
mailing list