[wasm-ld] Add __global_base symbol to mark the value of --global-base

Summary:
This is needed for address sanitizer on Emscripten. As everything in
memory starts at the value passed to --global-base, everything before
that can be used as shadow memory.

This symbol is added so that the library for the ASan runtime can know
where the shadow memory ends and real memory begins.

This is split from D63742.

Reviewers: tlively, aheejin, sbc100

Subscribers: sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63833

llvm-svn: 364467
This commit is contained in:
Guanzhong Chen
2019-06-26 20:12:33 +00:00
parent 8ac899c600
commit e15dc95466
5 changed files with 80 additions and 0 deletions

View File

@@ -224,6 +224,9 @@ void Writer::layoutMemory() {
log("mem: global base = " + Twine(Config->GlobalBase));
}
if (WasmSym::GlobalBase)
WasmSym::GlobalBase->setVirtualAddress(Config->GlobalBase);
uint32_t DataStart = MemoryPtr;
// Arbitrarily set __dso_handle handle to point to the start of the data