[PATCH] D42285: [WebAssembly] Allow non-zero table offset in input object

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 19:58:12 PST 2018


sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff, jfb.

This change enables https://reviews.llvm.org/D42284 to land without breaking lld


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D42285

Files:
  wasm/InputFiles.cpp
  wasm/Writer.cpp


Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -748,7 +748,7 @@
   for (ObjFile *File : Symtab->ObjectFiles) {
     DEBUG(dbgs() << "Table Indexes: " << File->getName() << "\n");
     for (Symbol *Sym : File->getTableSymbols()) {
-      if (Sym->hasTableIndex() || !Sym->hasOutputIndex())
+      if (!Sym || Sym->hasTableIndex() || !Sym->hasOutputIndex())
         continue;
       Sym->setTableIndex(TableIndex++);
       IndirectFunctions.emplace_back(Sym);
Index: wasm/InputFiles.cpp
===================================================================
--- wasm/InputFiles.cpp
+++ wasm/InputFiles.cpp
@@ -281,9 +281,9 @@
       fatal(getName() + ": unsupported element segment");
     if (Segment.TableIndex != 0)
       fatal(getName() + ": unsupported table index in elem segment");
-    if (Segment.Offset.Value.Int32 != 0)
-      fatal(getName() + ": unsupported element segment offset");
-    TableSymbols.reserve(Segment.Functions.size());
+    uint32_t Offset = Segment.Offset.Value.Int32;
+    TableSymbols.resize(Offset);
+    TableSymbols.reserve(Offset + Segment.Functions.size());
     for (uint64_t FunctionIndex : Segment.Functions)
       TableSymbols.push_back(FunctionSymbols[FunctionIndex]);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42285.130554.patch
Type: text/x-patch
Size: 1304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180119/918a3a21/attachment.bin>


More information about the llvm-commits mailing list