[ELF] - Do not error out when version declaration not found when building executable.

  When building executable usually version script is absent.
Before this patch error was shown in the case when
symbol name contained version and there was no script to match it.
  Instead of error out patch allows
to create new version declaration in this case and use it.
gnu linkers do the same.

That is PR28359.

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

llvm-svn: 274828
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index a0ebb02..f01bc94 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -186,6 +186,16 @@
       return Default ? I : (I | VERSYM_HIDDEN);
     ++I;
   }
+
+  // If we are not building shared and version script
+  // is not specified, then it is not a error, it is
+  // in common not to use script for linking executables.
+  // In this case we just create new version.
+  if (!Config->Shared && !Config->HasVersionScript) {
+    Config->SymbolVersions.push_back(elf::Version(Version));
+    return Default ? I : (I | VERSYM_HIDDEN);
+  }
+
   error("symbol " + Name + " has undefined version " + Version);
   return 0;
 }