[dev.link] cmd/link: handle runtime.text/etext symbols more consistently

Currently, on most platforms, the start/end symbols runtime.text
and runtime.etext are defined in symtab pass and assigned values
in address pass. In some cases (darwin+dynlink or AIX+external),
however, they are defined and assigned values in textaddress pass
(because they need non-zero sizes). Then their values get
overwritten in address pass. This is bad. The linker expects
their values to be consistent. In particular, in CL 239281,
findfunctab is split to two parts. The two parts need to have a
consistent view of the start/end symbols. If its value changes in
between, bad things can happen.

This CL fixes it by always defining runtime.text/etext symbols in
the textaddress pass.

Fix darwin and AIX builds.

Change-Id: Ifdc1bcb69d99be1b7e5b4fd31d473650c03e3b9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/240065
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Cherry Zhang 2020-06-25 22:22:59 -04:00
parent 1fdf5ba50c
commit a9a1217112
3 changed files with 11 additions and 20 deletions

View file

@ -2376,13 +2376,14 @@ const (
DeletedAutoSym = 'x'
)
func (ctxt *Link) xdefine(p string, t sym.SymKind, v int64) {
func (ctxt *Link) xdefine(p string, t sym.SymKind, v int64) loader.Sym {
ldr := ctxt.loader
s := ldr.CreateSymForUpdate(p, 0)
s.SetType(t)
s.SetValue(v)
s.SetSpecial(true)
s.SetLocal(true)
return s.Sym()
}
func datoff(ldr *loader.Loader, s loader.Sym, addr int64) int64 {