Revert "[WebAssembly] Improve invalid relocation error message"

This reverts commit 0805ec5f7b5c80474352531a99e721c30e73e77f.

llvm-svn: 357225
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 4697540..480257f 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -1141,6 +1141,18 @@
       File->TypeMap[Reloc.Index] = registerType(Types[Reloc.Index]);
       File->TypeIsUsed[Reloc.Index] = true;
       break;
+    case R_WASM_MEMORY_ADDR_SLEB:
+    case R_WASM_MEMORY_ADDR_I32:
+    case R_WASM_MEMORY_ADDR_LEB: {
+      DataSymbol *DataSym = File->getDataSymbol(Reloc.Index);
+      if (!Config->Relocatable && !isa<DefinedData>(DataSym) &&
+          !DataSym->isWeak())
+        error(File->getName() +
+              ": relocation of type R_WASM_MEMORY_ADDR_* "
+              "against undefined data symbol: " +
+              DataSym->getName());
+      break;
+    }
     case R_WASM_GLOBAL_INDEX_LEB: {
       auto* Sym = File->getSymbols()[Reloc.Index];
       if (!isa<GlobalSymbol>(Sym) && !Sym->isInGOT()) {
@@ -1149,23 +1161,6 @@
       }
     }
     }
-
-    if (!Config->Relocatable) {
-      switch (Reloc.Type) {
-      // These relocations types appear the code section.
-      // They should never appear in code compiled with -fPIC.
-      case R_WASM_TABLE_INDEX_SLEB:
-      case R_WASM_MEMORY_ADDR_I32:
-      case R_WASM_MEMORY_ADDR_LEB: {
-        auto *Sym = File->getSymbols()[Reloc.Index];
-        if (Sym->isUndefined() && !Sym->isWeak())
-          error(File->getName() + ": relocation " +
-                reloctTypeToString(Reloc.Type) +
-                " cannot be used againt symbol " + Sym->getName() +
-                "; recompile with -fPIC");
-      }
-      }
-    }
   }
 }