From f797e485e0acde9d2c5b458b61070985f4a3222d Mon Sep 17 00:00:00 2001 From: Hiroshi Ioka Date: Mon, 11 Sep 2017 07:51:57 +0900 Subject: [PATCH] cmd/link: don't generate runtime.text twice for buildmode=plugin on darwin https://golang.org/cl/29394 changed to include runtime.text and runtime.etext in ctxt.Textp as a work around. But it seems that the CL forgot to change genasmsym. As a result, we are generating runtime.text and runtime.etext twice. Change-Id: If7f8faf496c1c489ffa4804da712f91a3d3f4be4 Reviewed-on: https://go-review.googlesource.com/62810 Reviewed-by: David Crawshaw Run-TryBot: David Crawshaw TryBot-Result: Gobot Gobot --- src/cmd/link/internal/ld/lib.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 14821d8271..47c719b7b6 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1939,7 +1939,12 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, * // skip STEXT symbols. Normal STEXT symbols are emitted by walking textp. s := ctxt.Syms.Lookup("runtime.text", 0) if s.Type == STEXT { - put(ctxt, s, s.Name, TextSym, s.Value, nil) + // We've already included this symbol in ctxt.Textp + // if ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin. + // See data.go:/textaddress + if !(ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin) { + put(ctxt, s, s.Name, TextSym, s.Value, nil) + } } n := 0 @@ -1965,7 +1970,12 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, * s = ctxt.Syms.Lookup("runtime.etext", 0) if s.Type == STEXT { - put(ctxt, s, s.Name, TextSym, s.Value, nil) + // We've already included this symbol in ctxt.Textp + // if ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin. + // See data.go:/textaddress + if !(ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin) { + put(ctxt, s, s.Name, TextSym, s.Value, nil) + } } for _, s := range ctxt.Syms.Allsym {