Skip to content

Reset wasmSym symbols before every linkerMain call #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
@@ -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 "
29 changes: 29 additions & 0 deletions lld/wasm/Symbols.cpp
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions lld/wasm/Symbols.h
Original file line number Diff line number Diff line change
@@ -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;