From: Cherry Mui Date: Wed, 12 May 2021 16:30:34 +0000 (-0400) Subject: cmd/link: start at address 0 when external linking X-Git-Tag: go1.18beta1~1771 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c92f5ee170e6f9c639f1ca684061a0cedde54108;p=gostls13.git cmd/link: start at address 0 when external linking When external linking, we are creating an object file, instead of a executable. The absolute address is irrelevant. The external linker will set it up. Start at address 0. Change-Id: I3a2e0b8087b328d5c3144f29ca8ba6311aa39cba Reviewed-on: https://go-review.googlesource.com/c/go/+/319830 Trust: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Go Bot Reviewed-by: Than McIntosh --- diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 644faeb2fb..894e5afe63 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -697,7 +697,9 @@ func (ctxt *Link) linksetup() { Peinit(ctxt) } - if ctxt.HeadType == objabi.Hdarwin && ctxt.LinkMode == LinkExternal { + if ctxt.LinkMode == LinkExternal { + // When external linking, we are creating an object file. The + // absolute address is irrelevant. *FlagTextAddr = 0 } diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go index 8eb4231c3a..871bf8de2b 100644 --- a/src/cmd/link/internal/ld/pe.go +++ b/src/cmd/link/internal/ld/pe.go @@ -1061,6 +1061,8 @@ func Peinit(ctxt *Link) { // linker will honour that requirement. PESECTALIGN = 32 PEFILEALIGN = 0 + // We are creating an object file. The absolute address is irrelevant. + PEBASE = 0 } var sh [16]pe.SectionHeader32