[ELF2] Add --undefined option

Add symbol specified with -u as undefined which may cause additional
object files from archives to be linked into the resulting binary.

Differential Revision: http://reviews.llvm.org/D13345

llvm-svn: 249295
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index cd9b760..c7dbafe 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -334,8 +334,10 @@
   for (auto &P : Symtab.getSymbols()) {
     StringRef Name = P.first;
     SymbolBody *Body = P.second->Body;
-    if (Body->isStrongUndefined())
-      reportUndefined<ELFT>(Symtab, *Body);
+    if (auto *U = dyn_cast<Undefined<ELFT>>(Body)) {
+      if (!U->isWeak() && !U->canKeepUndefined())
+        reportUndefined<ELFT>(Symtab, *Body);
+    }
 
     if (auto *C = dyn_cast<DefinedCommon<ELFT>>(Body))
       CommonSymbols.push_back(C);