Turn resolution.s into an exhaustive testcase.

Now that we print a symbol table and all symbol kinds are at least declared,
we can test all combinations that don't produce an error.

This also includes a few fixes to keep the test passing:

* Keep the strong symbol in a weak X strong pair
* Handle common symbols.

The common X common case will be finished in a followup patch.

llvm-svn: 246401
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 33f9a7e..d12db27 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -20,8 +20,8 @@
 // Returns 1, 0 or -1 if this symbol should take precedence
 // over the Other, tie or lose, respectively.
 int SymbolBody::compare(SymbolBody *Other) {
-  std::pair<bool, bool> L(isDefined(), isWeak());
-  std::pair<bool, bool> R(Other->isDefined(), Other->isWeak());
+  std::pair<bool, bool> L(isDefined(), !isWeak());
+  std::pair<bool, bool> R(Other->isDefined(), !Other->isWeak());
 
   // Normalize
   if (L > R)
@@ -30,7 +30,14 @@
   if (L != R)
     return -1;
 
-  if (L.first && !L.second)
+  if (L.first && L.second) {
+    // FIXME: In the case where both are common we need to pick the largest
+    // and remember the alignment restriction.
+    if (isCommon())
+      return -1;
+    if (Other->isCommon())
+      return 1;
     return 0;
+  }
   return 1;
 }