Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lld/wasm/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
auto *context = new CommonLinkerContext;

context->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput);
context->e.cleanupCallback = []() { ctx.reset(); };
context->e.cleanupCallback = []() {
ctx.reset();
WasmSym::reset(); // manually clear globals
};
context->e.logName = args::getFilenameWithoutExe(args[0]);
context->e.errorLimitExceededMsg =
"too many errors emitted, stopping now (use "
Expand Down
29 changes: 29 additions & 0 deletions lld/wasm/Symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,35 @@ UndefinedGlobal *WasmSym::memoryBase;
DefinedData *WasmSym::definedMemoryBase;
TableSymbol *WasmSym::indirectFunctionTable;

void WasmSym::reset() {
callCtors = nullptr;
callDtors = nullptr;
initMemory = nullptr;
applyGlobalRelocs = nullptr;
applyTLSRelocs = nullptr;
applyGlobalTLSRelocs = nullptr;
initTLS = nullptr;
firstPageEnd = nullptr;
startFunction = nullptr;
dsoHandle = nullptr;
dataEnd = nullptr;
globalBase = nullptr;
heapBase = nullptr;
heapEnd = nullptr;
initMemoryFlag = nullptr;
stackPointer = nullptr;
stackLow = nullptr;
stackHigh = nullptr;
tlsBase = nullptr;
tlsSize = nullptr;
tlsAlign = nullptr;
tableBase = nullptr;
definedTableBase = nullptr;
memoryBase = nullptr;
definedMemoryBase = nullptr;
indirectFunctionTable = nullptr;
}

WasmSymbolType Symbol::getWasmType() const {
if (isa<FunctionSymbol>(this))
return WASM_SYMBOL_TYPE_FUNCTION;
Expand Down
1 change: 1 addition & 0 deletions lld/wasm/Symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ class LazySymbol : public Symbol {

// linker-generated symbols
struct WasmSym {
static void reset();
// __global_base
// Symbol marking the start of the global section.
static DefinedData *globalBase;
Expand Down