Commit 4e3a1e40 authored by Alex Brainman's avatar Alex Brainman

cmd/link/internal/ld: introduce and use windowsgui variable

cmd/link -H flag is stored in variable of type
cmd/internal/obj.HeadType. The HeadType type from cmd/internal/obj
accepts Hwindows and Hwindowsgui values, but these values have
same meaning - build PE executable, except for 2 places in
cmd/link/internal/ld package.

This CL introduces code to store cmd/link "windowsgui" -H flag
in cmd/link/internal/ld, so cmd/internal/obj.Hwindowsgui can be
removed in the next CL.

This CL also includes 2 changes to code where distinction
between Hwindows and Hwindowsgui is important.

Change-Id: Ie5ee1f374e50c834652a037f2770118d56c21a2a
Reviewed-on: https://go-review.googlesource.com/38760Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 94c62efe
......@@ -1026,9 +1026,11 @@ func (l *Link) hostlink() {
case obj.Hopenbsd:
argv = append(argv, "-Wl,-nopie")
case obj.Hwindows:
argv = append(argv, "-mconsole")
case obj.Hwindowsgui:
argv = append(argv, "-mwindows")
if windowsgui {
argv = append(argv, "-mwindows")
} else {
argv = append(argv, "-mconsole")
}
}
switch Buildmode {
......
......@@ -44,12 +44,12 @@ import (
var (
pkglistfornote []byte
windowsgui bool // writes a "GUI binary" instead of a "console binary"
)
func init() {
flag.Var(&Linkmode, "linkmode", "set link `mode`")
flag.Var(&Buildmode, "buildmode", "set build `mode`")
flag.Var(&Headtype, "H", "set header `type`")
flag.Var(&rpath, "r", "set the ELF dynamic linker search `path` to dir1:dir2:...")
}
......@@ -88,6 +88,7 @@ var (
flagInterpreter = flag.String("I", "", "use `linker` as ELF dynamic linker")
FlagDebugTramp = flag.Int("debugtramp", 0, "debug trampolines")
flagHeadtype = flag.String("H", "", "set header `type`")
FlagRound = flag.Int("R", -1, "set address rounding `quantum`")
FlagTextAddr = flag.Int64("T", -1, "set text segment `address`")
FlagDataAddr = flag.Int64("D", -1, "set data segment `address`")
......@@ -124,6 +125,18 @@ func Main() {
obj.Flagparse(usage)
switch *flagHeadtype {
case "":
case "windowsgui":
Headtype = obj.Hwindows
windowsgui = true
default:
if err := Headtype.Set(*flagHeadtype); err != nil {
Errorf(nil, "%v", err)
usage()
}
}
startProfile()
if Buildmode == BuildmodeUnset {
Buildmode = BuildmodeExe
......
......@@ -1292,7 +1292,7 @@ func Asmbpe(ctxt *Link) {
oh.SizeOfImage = uint32(nextsectoff)
oh64.SizeOfHeaders = uint32(PEFILEHEADR)
oh.SizeOfHeaders = uint32(PEFILEHEADR)
if Headtype == obj.Hwindowsgui {
if windowsgui {
oh64.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI
oh.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment