]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/link: start at address 0 when external linking
authorCherry Mui <cherryyz@google.com>
Wed, 12 May 2021 16:30:34 +0000 (12:30 -0400)
committerCherry Mui <cherryyz@google.com>
Mon, 16 Aug 2021 16:20:06 +0000 (16:20 +0000)
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 <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/pe.go

index 644faeb2fbc2fd039b65681621a296cc700d2e53..894e5afe6387754f60763d7d76e44a11d68f0eb0 100644 (file)
@@ -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
        }
 
index 8eb4231c3ab2895f095e2b1197e92d60659eb177..871bf8de2b158f3710bc9125e12e995954b47a1f 100644 (file)
@@ -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