]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: define _etext, etc. in the linker on Solaris
authorCherry Zhang <cherryyz@google.com>
Wed, 25 Mar 2020 21:10:16 +0000 (17:10 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 26 Mar 2020 14:23:41 +0000 (14:23 +0000)
On Solaris, in the runtime it defines the external name of
runtime.etext as _etext (runtime/os3_solaris.go:13). In CL 224939
we changed to put external names in the ELF symbol table more
consistently. In this case it will contain _etext but not
runtime.etext.

To be conservative, this CL defines both runtime.etext and _text
in the linker.

Change-Id: I79f196e87b655042be97b0fbbab02d0ebc8db2fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/225537
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/data.go

index cb0c9d8d25c09ee22aaac8890294ec92abb9b84a..8c240f4d9078a1c3eceaec7097b2dec5f4f6c11c 100644 (file)
@@ -2419,6 +2419,24 @@ func (ctxt *Link) address() []*sym.Segment {
        ctxt.xdefine("runtime.enoptrbss", sym.SNOPTRBSS, int64(noptrbss.Vaddr+noptrbss.Length))
        ctxt.xdefine("runtime.end", sym.SBSS, int64(Segdata.Vaddr+Segdata.Length))
 
+       if ctxt.IsSolaris() {
+               // On Solaris, in the runtime it sets the external names of the
+               // end symbols. Unset them and define separate symbols, so we
+               // keep both.
+               etext := ctxt.Syms.ROLookup("runtime.etext", 0)
+               edata := ctxt.Syms.ROLookup("runtime.edata", 0)
+               end := ctxt.Syms.ROLookup("runtime.end", 0)
+               etext.SetExtname("runtime.etext")
+               edata.SetExtname("runtime.edata")
+               end.SetExtname("runtime.end")
+               ctxt.xdefine("_etext", etext.Type, etext.Value)
+               ctxt.xdefine("_edata", edata.Type, edata.Value)
+               ctxt.xdefine("_end", end.Type, end.Value)
+               ctxt.Syms.ROLookup("_etext", 0).Sect = etext.Sect
+               ctxt.Syms.ROLookup("_edata", 0).Sect = edata.Sect
+               ctxt.Syms.ROLookup("_end", 0).Sect = end.Sect
+       }
+
        return order
 }