[ELF] - handle of command line options incompatible with -r

Patch handles the command line options
incompatible with relocatable output.

Differential revision: http://reviews.llvm.org/D17758

llvm-svn: 262377
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index d6a659d..70be155 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -141,8 +141,15 @@
   if (Config->EMachine == EM_AMDGPU && !Config->Entry.empty())
     error("-e option is not valid for AMDGPU.");
 
-  if (Config->Relocatable && Config->Shared)
+  if (!Config->Relocatable)
+    return;
+
+  if (Config->Shared)
     error("-r and -shared may not be used together");
+  if (Config->GcSections)
+    error("-r and --gc-sections may not be used together");
+  if (Config->ICF)
+    error("-r and --icf may not be used together");
 }
 
 static StringRef