From 7f02fa72aaa01fba1f66adcf2fa4414154a6d6fa Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Wed, 26 Feb 2020 14:18:35 -0500 Subject: [PATCH] [dev.link] cmd/link: convert Peinit to use the loader There is one use of sym.Symbol in Peinit, which is called from linksetup, which is before loadlibfull. Convert this one. Change-Id: Iedb8b0e0c5c292bccf5c9bd5d092ee434a4ebdbd Reviewed-on: https://go-review.googlesource.com/c/go/+/221177 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Jeremy Faller --- src/cmd/link/internal/ld/pe.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go index e20d7da9aa..6f6d5b2e5a 100644 --- a/src/cmd/link/internal/ld/pe.go +++ b/src/cmd/link/internal/ld/pe.go @@ -978,8 +978,15 @@ func Peinit(ctxt *Link) { if ctxt.LinkMode == LinkInternal { // some mingw libs depend on this symbol, for example, FindPESectionByName - ctxt.xdefine("__image_base__", sym.SDATA, PEBASE) - ctxt.xdefine("_image_base__", sym.SDATA, PEBASE) + for _, name := range [2]string{"__image_base__", "_image_base__"} { + s := ctxt.loader.LookupOrCreateSym(name, 0) + sb := ctxt.loader.MakeSymbolUpdater(s) + sb.SetType(sym.SDATA) + sb.SetValue(PEBASE) + ctxt.loader.SetAttrReachable(s, true) + ctxt.loader.SetAttrSpecial(s, true) + ctxt.loader.SetAttrLocal(s, true) + } } HEADR = PEFILEHEADR