Index: lld/trunk/wasm/InputFiles.cpp =================================================================== --- lld/trunk/wasm/InputFiles.cpp +++ lld/trunk/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]); } Index: lld/trunk/wasm/Writer.cpp =================================================================== --- lld/trunk/wasm/Writer.cpp +++ lld/trunk/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);