[lld] r322976 - [WebAssembly] Allow non-zero table offset in input object
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 10:21:42 PST 2018
Author: sbc
Date: Fri Jan 19 10:21:42 2018
New Revision: 322976
URL: http://llvm.org/viewvc/llvm-project?rev=322976&view=rev
Log:
[WebAssembly] Allow non-zero table offset in input object
Summary: This change enables D42284 to land without breaking lld
Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D42285
Modified:
lld/trunk/wasm/InputFiles.cpp
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/wasm/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputFiles.cpp?rev=322976&r1=322975&r2=322976&view=diff
==============================================================================
--- lld/trunk/wasm/InputFiles.cpp (original)
+++ lld/trunk/wasm/InputFiles.cpp Fri Jan 19 10:21:42 2018
@@ -281,9 +281,9 @@ void ObjFile::initializeSymbols() {
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]);
}
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=322976&r1=322975&r2=322976&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Fri Jan 19 10:21:42 2018
@@ -748,7 +748,7 @@ void Writer::assignIndexes() {
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);
More information about the llvm-commits
mailing list