Index: lld/wasm/Writer.cpp =================================================================== --- lld/wasm/Writer.cpp +++ lld/wasm/Writer.cpp @@ -578,6 +578,7 @@ debugPrint("mem: global base = %d\n", Config->GlobalBase); } + uint32_t DataStart = MemoryPtr; createOutputSegments(); // Arbitrarily set __dso_handle handle to point to the start of the data @@ -597,9 +598,7 @@ if (WasmSym::DataEnd) WasmSym::DataEnd->setVirtualAddress(MemoryPtr); - DataSize = MemoryPtr; - if (!Config->Relocatable) - DataSize -= Config->GlobalBase; + DataSize = MemoryPtr - DataStart; debugPrint("mem: static data = %d\n", DataSize); // Stack comes after static data and bss