]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: set runtime.text to the address of the first function
authorCherry Zhang <cherryyz@google.com>
Mon, 12 Oct 2020 22:00:25 +0000 (18:00 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 13 Oct 2020 14:50:14 +0000 (14:50 +0000)
In CL 240065 we changed it to set to FlagTextAddr. Normally it
is the address of the first function, except on plan9/amd64
where, as FlagTextAddr is not aligned, it is rounded up. Set it
to the actual text start address.

Fixes #41137.

Change-Id: I1bba67f5eb4e24d9f745a11350fc999ff48bff45
Reviewed-on: https://go-review.googlesource.com/c/go/+/261644
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/data.go

index 3cd7b4ad0b45ad99c093159254a8f4f50ac034de..84e03a4011396f4eb220d8b7d3ff71f297ff3418 100644 (file)
@@ -2188,7 +2188,7 @@ func (ctxt *Link) textaddress() {
                ctxt.Textp[0] = text
        }
 
-       va := uint64(*FlagTextAddr)
+       va := uint64(Rnd(*FlagTextAddr, int64(Funcalign)))
        n := 1
        sect.Vaddr = va
        ntramps := 0
@@ -2214,7 +2214,7 @@ func (ctxt *Link) textaddress() {
                // Set the address of the start/end symbols, if not already
                // (i.e. not darwin+dynlink or AIX+external, see above).
                ldr.SetSymValue(etext, int64(va))
-               ldr.SetSymValue(text, *FlagTextAddr)
+               ldr.SetSymValue(text, int64(Segtext.Sections[0].Vaddr))
        }
 
        // merge tramps into Textp, keeping Textp in address order