ELF: Add --strip-debug option.

If --strip-debug option is given, then all sections whose names start
with ".debug" are removed from output.

llvm-svn: 265722
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 6eb2dc6..1aa0318 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -262,8 +262,13 @@
   if (Name == ".note.GNU-stack")
     return &InputSection<ELFT>::Discarded;
 
-  if (Name == ".note.GNU-split-stack")
+  if (Name == ".note.GNU-split-stack") {
     error("objects using splitstacks are not supported");
+    return &InputSection<ELFT>::Discarded;
+  }
+
+  if (Config->StripDebug && Name.startswith(".debug"))
+    return &InputSection<ELFT>::Discarded;
 
   // A MIPS object file has a special section that contains register
   // usage info, which needs to be handled by the linker specially.