diff options
author | Heschi Kreinick <heschi@google.com> | 2021-10-07 19:02:56 -0400 |
---|---|---|
committer | Heschi Kreinick <heschi@google.com> | 2021-10-07 19:02:56 -0400 |
commit | 35d5cd0dcfb9d06064ec37da1621d24676454058 (patch) | |
tree | 5319064d4c2970a6d3be069b9c2a0e273f0f14dd /src/cmd/link/internal/ld/data.go | |
parent | 0d02a0d966b6d307ac33e3df3687948b74408569 (diff) | |
parent | c580180744e60d6c84fc0b59d634fcff01290780 (diff) | |
download | go-35d5cd0dcfb9d06064ec37da1621d24676454058.tar.gz go-35d5cd0dcfb9d06064ec37da1621d24676454058.zip |
[dev.boringcrypto.go1.16] all: merge go1.16.9 into dev.boringcrypto.go1.16
Change-Id: Ic26e9802fe13c491fcc26f34b8847779ac43cfe2
Diffstat (limited to 'src/cmd/link/internal/ld/data.go')
-rw-r--r-- | src/cmd/link/internal/ld/data.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index 52035e9630..54a1d188cd 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -2330,6 +2330,11 @@ func assignAddress(ctxt *Link, sect *sym.Section, n int, s loader.Sym, va uint64 return sect, n, va } +// On Wasm, we reserve 4096 bytes for zero page, then 4096 bytes for wasm_exec.js +// to store command line args. Data sections starts from at least address 8192. +// Keep in sync with wasm_exec.js. +const wasmMinDataAddr = 4096 + 4096 + // address assigns virtual addresses to all segments and sections and // returns all segments in file order. func (ctxt *Link) address() []*sym.Segment { @@ -2339,10 +2344,14 @@ func (ctxt *Link) address() []*sym.Segment { order = append(order, &Segtext) Segtext.Rwx = 05 Segtext.Vaddr = va - for _, s := range Segtext.Sections { + for i, s := range Segtext.Sections { va = uint64(Rnd(int64(va), int64(s.Align))) s.Vaddr = va va += s.Length + + if ctxt.IsWasm() && i == 0 && va < wasmMinDataAddr { + va = wasmMinDataAddr + } } Segtext.Length = va - uint64(*FlagTextAddr) |