diff options
| -rw-r--r-- | lld/wasm/MarkLive.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp index bba1b9d8b35..1e00ca04ea2 100644 --- a/lld/wasm/MarkLive.cpp +++ b/lld/wasm/MarkLive.cpp @@ -61,33 +61,33 @@ void lld::wasm::markLive() { // The ctor functions are all used in the synthetic __wasm_call_ctors // function, but since this function is created in-place it doesn't contain - // reloctations which mean we have to manually mark the ctors. + // relocations which mean we have to manually mark the ctors. for (const ObjFile *Obj : Symtab->ObjectFiles) { const WasmLinkingData &L = Obj->getWasmObj()->linkingData(); for (const WasmInitFunc &F : L.InitFunctions) Enqueue(Obj->getFunctionSymbol(F.FunctionIndex)); } - auto EnqueueSuccessors = [Enqueue](InputChunk &Chunk) { - for (const WasmRelocation Reloc : Chunk.getRelocations()) { + // Follow relocations to mark all reachable chunks. + while (!Q.empty()) { + 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(Chunk.File->getFunctionSymbol(Reloc.Index)); + 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(Chunk.File->getGlobalSymbol(Reloc.Index)); + Enqueue(C->File->getGlobalSymbol(Reloc.Index)); break; } } - }; - - while (!Q.empty()) - EnqueueSuccessors(*Q.pop_back_val()); + } // Report garbage-collected sections. if (Config->PrintGcSections) { |

