Skip to content

Commit

Permalink
cmd/link: set runtime.text to the address of the first function
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Cherry Zhang <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: David du Colombier <[email protected]>
Reviewed-by: Than McIntosh <[email protected]>
  • Loading branch information
cherrymui committed Oct 13, 2020
1 parent 5b509d9 commit 575ea5a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cmd/link/internal/ld/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 575ea5a

Please sign in to comment.