[WebAssembly] Add explicit symbol table

This change modified lld to in response the llvm change which
moved to a more explicit symbol table in the object format.

Based on patches by Nicholas Wilson:
 1. https://reviews.llvm.org/D41955
 2. https://reviews.llvm.org/D42585

The primary difference that we see in the test output is that
for relocatable (-r) output we now have symbol table which
replaces exports/imports and globals.

See: https://github.com/WebAssembly/tool-conventions/issues/38
Differential Revision: https://reviews.llvm.org/D43264

llvm-svn: 325861
diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp
index dbeccee..22211c1 100644
--- a/lld/wasm/MarkLive.cpp
+++ b/lld/wasm/MarkLive.cpp
@@ -65,7 +65,7 @@
   for (const ObjFile *Obj : Symtab->ObjectFiles) {
     const WasmLinkingData &L = Obj->getWasmObj()->linkingData();
     for (const WasmInitFunc &F : L.InitFunctions)
-      Enqueue(Obj->getFunctionSymbol(F.FunctionIndex));
+      Enqueue(Obj->getFunctionSymbol(F.Symbol));
   }
 
   // Follow relocations to mark all reachable chunks.
@@ -73,19 +73,8 @@
     InputChunk *C = Q.pop_back_val();
 
     for (const WasmRelocation Reloc : C->getRelocations()) {
-      switch (Reloc.Type) {
-      case R_WEBASSEMBLY_FUNCTION_INDEX_LEB:
-      case R_WEBASSEMBLY_TABLE_INDEX_I32:
-      case R_WEBASSEMBLY_TABLE_INDEX_SLEB:
-        Enqueue(C->File->getFunctionSymbol(Reloc.Index));
-        break;
-      case R_WEBASSEMBLY_GLOBAL_INDEX_LEB:
-      case R_WEBASSEMBLY_MEMORY_ADDR_LEB:
-      case R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
-      case R_WEBASSEMBLY_MEMORY_ADDR_I32:
-        Enqueue(C->File->getDataSymbol(Reloc.Index));
-        break;
-      }
+      if (Reloc.Type != R_WEBASSEMBLY_TYPE_INDEX_LEB)
+        Enqueue(C->File->getSymbol(Reloc.Index));
     }
   }