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>
}
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 {
// 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
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() {
}
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 {