1
0
mirror of https://github.com/golang/go synced 2024-11-17 20:24:46 -07:00

[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 <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-02-26 14:18:35 -05:00
parent b9642cbb8d
commit 7f02fa72aa

View File

@ -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