mirror of
https://github.com/golang/go
synced 2024-11-24 05:30:24 -07:00
cmd/link: delay calculating pe file parameters after Linkmode is set
For #10776. Change-Id: Id64a7e35c7cdcd9be16cbe3358402fa379090e36 Reviewed-on: https://go-review.googlesource.com/36975 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
e31144f128
commit
0ad247c6f0
@ -142,18 +142,8 @@ func archinit(ctxt *ld.Link) {
|
||||
}
|
||||
|
||||
case obj.Hwindows, obj.Hwindowsgui: /* PE executable */
|
||||
ld.Peinit(ctxt)
|
||||
|
||||
ld.HEADR = ld.PEFILEHEADR
|
||||
if *ld.FlagTextAddr == -1 {
|
||||
*ld.FlagTextAddr = ld.PEBASE + int64(ld.PESECTHEADR)
|
||||
}
|
||||
if *ld.FlagDataAddr == -1 {
|
||||
*ld.FlagDataAddr = 0
|
||||
}
|
||||
if *ld.FlagRound == -1 {
|
||||
*ld.FlagRound = int(ld.PESECTALIGN)
|
||||
}
|
||||
// ld.HEADR, ld.FlagTextAddr, ld.FlagDataAddr and ld.FlagRound are set in ld.Peinit
|
||||
return
|
||||
}
|
||||
|
||||
if *ld.FlagDataAddr != 0 && *ld.FlagRound != 0 {
|
||||
|
@ -430,6 +430,11 @@ func (ctxt *Link) loadlib() {
|
||||
// We now have enough information to determine the link mode.
|
||||
determineLinkMode(ctxt)
|
||||
|
||||
// Recalculate pe parameters now that we have Linkmode set.
|
||||
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui {
|
||||
Peinit(ctxt)
|
||||
}
|
||||
|
||||
if Linkmode == LinkExternal && SysArch.Family == sys.PPC64 {
|
||||
toc := ctxt.Syms.Lookup(".TOC.", 0)
|
||||
toc.Type = obj.SDYNIMPORT
|
||||
|
@ -455,6 +455,20 @@ func Peinit(ctxt *Link) {
|
||||
ctxt.xdefine("__image_base__", obj.SDATA, PEBASE)
|
||||
|
||||
ctxt.xdefine("_image_base__", obj.SDATA, PEBASE)
|
||||
|
||||
HEADR = PEFILEHEADR
|
||||
if *FlagTextAddr == -1 {
|
||||
*FlagTextAddr = PEBASE + int64(PESECTHEADR)
|
||||
}
|
||||
if *FlagDataAddr == -1 {
|
||||
*FlagDataAddr = 0
|
||||
}
|
||||
if *FlagRound == -1 {
|
||||
*FlagRound = int(PESECTALIGN)
|
||||
}
|
||||
if *FlagDataAddr != 0 && *FlagRound != 0 {
|
||||
fmt.Printf("warning: -D0x%x is ignored because of -R0x%x\n", uint64(*FlagDataAddr), uint32(*FlagRound))
|
||||
}
|
||||
}
|
||||
|
||||
func pewrite() {
|
||||
|
@ -134,18 +134,8 @@ func archinit(ctxt *ld.Link) {
|
||||
}
|
||||
|
||||
case obj.Hwindows, obj.Hwindowsgui: /* PE executable */
|
||||
ld.Peinit(ctxt)
|
||||
|
||||
ld.HEADR = ld.PEFILEHEADR
|
||||
if *ld.FlagTextAddr == -1 {
|
||||
*ld.FlagTextAddr = ld.PEBASE + int64(ld.PESECTHEADR)
|
||||
}
|
||||
if *ld.FlagDataAddr == -1 {
|
||||
*ld.FlagDataAddr = 0
|
||||
}
|
||||
if *ld.FlagRound == -1 {
|
||||
*ld.FlagRound = int(ld.PESECTALIGN)
|
||||
}
|
||||
// ld.HEADR, ld.FlagTextAddr, ld.FlagDataAddr and ld.FlagRound are set in ld.Peinit
|
||||
return
|
||||
}
|
||||
|
||||
if *ld.FlagDataAddr != 0 && *ld.FlagRound != 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user