Commit 361af94d authored by Alex Brainman's avatar Alex Brainman

cmd/internal/obj, cmd/link: remove Hwindowsgui everywhere

Hwindowsgui has the same meaning as Hwindows - build PE
executable. So use Hwindows everywhere.

Change-Id: I2cae5777f17c7bc3a043dfcd014c1620cc35fc20
Reviewed-on: https://go-review.googlesource.com/38761Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 4e3a1e40
...@@ -810,7 +810,6 @@ const ( ...@@ -810,7 +810,6 @@ const (
Hplan9 Hplan9
Hsolaris Hsolaris
Hwindows Hwindows
Hwindowsgui
) )
func (h *HeadType) Set(s string) error { func (h *HeadType) Set(s string) error {
...@@ -835,8 +834,6 @@ func (h *HeadType) Set(s string) error { ...@@ -835,8 +834,6 @@ func (h *HeadType) Set(s string) error {
*h = Hsolaris *h = Hsolaris
case "windows": case "windows":
*h = Hwindows *h = Hwindows
case "windowsgui":
*h = Hwindowsgui
default: default:
return fmt.Errorf("invalid headtype: %q", s) return fmt.Errorf("invalid headtype: %q", s)
} }
...@@ -865,8 +862,6 @@ func (h *HeadType) String() string { ...@@ -865,8 +862,6 @@ func (h *HeadType) String() string {
return "solaris" return "solaris"
case Hwindows: case Hwindows:
return "windows" return "windows"
case Hwindowsgui:
return "windowsgui"
} }
return fmt.Sprintf("HeadType(%d)", *h) return fmt.Sprintf("HeadType(%d)", *h)
} }
...@@ -4120,7 +4120,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) { ...@@ -4120,7 +4120,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
asmbuf.Put1(0x8B) asmbuf.Put1(0x8B)
asmbuf.asmand(ctxt, cursym, p, &pp.From, &p.To) asmbuf.asmand(ctxt, cursym, p, &pp.From, &p.To)
case obj.Hwindows, obj.Hwindowsgui: case obj.Hwindows:
// Windows TLS base is always 0x14(FS). // Windows TLS base is always 0x14(FS).
pp.From = p.From pp.From = p.From
...@@ -4192,7 +4192,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) { ...@@ -4192,7 +4192,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
0x8B) 0x8B)
asmbuf.asmand(ctxt, cursym, p, &pp.From, &p.To) asmbuf.asmand(ctxt, cursym, p, &pp.From, &p.To)
case obj.Hwindows, obj.Hwindowsgui: case obj.Hwindows:
// Windows TLS base is always 0x28(GS). // Windows TLS base is always 0x28(GS).
pp.From = p.From pp.From = p.From
......
...@@ -54,8 +54,7 @@ func CanUse1InsnTLS(ctxt *obj.Link) bool { ...@@ -54,8 +54,7 @@ func CanUse1InsnTLS(ctxt *obj.Link) bool {
case obj.Hlinux, case obj.Hlinux,
obj.Hnacl, obj.Hnacl,
obj.Hplan9, obj.Hplan9,
obj.Hwindows, obj.Hwindows:
obj.Hwindowsgui:
return false return false
} }
...@@ -63,7 +62,7 @@ func CanUse1InsnTLS(ctxt *obj.Link) bool { ...@@ -63,7 +62,7 @@ func CanUse1InsnTLS(ctxt *obj.Link) bool {
} }
switch ctxt.Headtype { switch ctxt.Headtype {
case obj.Hplan9, obj.Hwindows, obj.Hwindowsgui: case obj.Hplan9, obj.Hwindows:
return false return false
case obj.Hlinux: case obj.Hlinux:
return !ctxt.Flag_shared return !ctxt.Flag_shared
...@@ -163,7 +162,7 @@ func progedit(ctxt *obj.Link, p *obj.Prog) { ...@@ -163,7 +162,7 @@ func progedit(ctxt *obj.Link, p *obj.Prog) {
} }
// TODO: Remove. // TODO: Remove.
if (ctxt.Headtype == obj.Hwindows || ctxt.Headtype == obj.Hwindowsgui) && ctxt.Arch.Family == sys.AMD64 || ctxt.Headtype == obj.Hplan9 { if ctxt.Headtype == obj.Hwindows && ctxt.Arch.Family == sys.AMD64 || ctxt.Headtype == obj.Hplan9 {
if p.From.Scale == 1 && p.From.Index == REG_TLS { if p.From.Scale == 1 && p.From.Index == REG_TLS {
p.From.Scale = 2 p.From.Scale = 2
} }
......
...@@ -228,7 +228,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -228,7 +228,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
// nothing to do, the relocation will be laid out in reloc // nothing to do, the relocation will be laid out in reloc
return true return true
} }
if ld.Headtype == obj.Hwindows || ld.Headtype == obj.Hwindowsgui { if ld.Headtype == obj.Hwindows {
// nothing to do, the relocation will be laid out in pereloc1 // nothing to do, the relocation will be laid out in pereloc1
return true return true
} else { } else {
...@@ -342,7 +342,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -342,7 +342,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
return true return true
} }
if ld.Headtype == obj.Hwindows || ld.Headtype == obj.Hwindowsgui { if ld.Headtype == obj.Hwindows {
// nothing to do, the relocation will be laid out in pereloc1 // nothing to do, the relocation will be laid out in pereloc1
return true return true
} }
...@@ -718,8 +718,7 @@ func asmb(ctxt *ld.Link) { ...@@ -718,8 +718,7 @@ func asmb(ctxt *ld.Link) {
ld.Flag8 = true /* 64-bit addresses */ ld.Flag8 = true /* 64-bit addresses */
case obj.Hnacl, case obj.Hnacl,
obj.Hwindows, obj.Hwindows:
obj.Hwindowsgui:
break break
} }
...@@ -750,8 +749,7 @@ func asmb(ctxt *ld.Link) { ...@@ -750,8 +749,7 @@ func asmb(ctxt *ld.Link) {
symo = int64(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen) symo = int64(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = ld.Rnd(symo, int64(*ld.FlagRound)) symo = ld.Rnd(symo, int64(*ld.FlagRound))
case obj.Hwindows, case obj.Hwindows:
obj.Hwindowsgui:
symo = int64(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen) symo = int64(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = ld.Rnd(symo, ld.PEFILEALIGN) symo = ld.Rnd(symo, ld.PEFILEALIGN)
} }
...@@ -788,7 +786,7 @@ func asmb(ctxt *ld.Link) { ...@@ -788,7 +786,7 @@ func asmb(ctxt *ld.Link) {
ld.Cflush() ld.Cflush()
} }
case obj.Hwindows, obj.Hwindowsgui: case obj.Hwindows:
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog != 0 {
ctxt.Logf("%5.2f dwarf\n", obj.Cputime()) ctxt.Logf("%5.2f dwarf\n", obj.Cputime())
} }
...@@ -833,8 +831,7 @@ func asmb(ctxt *ld.Link) { ...@@ -833,8 +831,7 @@ func asmb(ctxt *ld.Link) {
obj.Hnacl: obj.Hnacl:
ld.Asmbelf(ctxt, symo) ld.Asmbelf(ctxt, symo)
case obj.Hwindows, case obj.Hwindows:
obj.Hwindowsgui:
ld.Asmbpe(ctxt) ld.Asmbpe(ctxt)
} }
......
...@@ -141,7 +141,7 @@ func archinit(ctxt *ld.Link) { ...@@ -141,7 +141,7 @@ func archinit(ctxt *ld.Link) {
*ld.FlagRound = 0x10000 *ld.FlagRound = 0x10000
} }
case obj.Hwindows, obj.Hwindowsgui: /* PE executable */ case obj.Hwindows: /* PE executable */
// ld.HEADR, ld.FlagTextAddr, ld.FlagDataAddr and ld.FlagRound are set in ld.Peinit // ld.HEADR, ld.FlagTextAddr, ld.FlagDataAddr and ld.FlagRound are set in ld.Peinit
return return
} }
......
...@@ -474,7 +474,7 @@ func relocsym(ctxt *Link, s *Symbol) { ...@@ -474,7 +474,7 @@ func relocsym(ctxt *Link, s *Symbol) {
o = 8 + r.Sym.Value o = 8 + r.Sym.Value
} else if Iself || Headtype == obj.Hplan9 || Headtype == obj.Hdarwin || isAndroidX86 { } else if Iself || Headtype == obj.Hplan9 || Headtype == obj.Hdarwin || isAndroidX86 {
o = int64(ctxt.Tlsoffset) + r.Add o = int64(ctxt.Tlsoffset) + r.Add
} else if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui { } else if Headtype == obj.Hwindows {
o = r.Add o = r.Add
} else { } else {
log.Fatalf("unexpected R_TLS_LE relocation for %v", Headtype) log.Fatalf("unexpected R_TLS_LE relocation for %v", Headtype)
...@@ -548,7 +548,7 @@ func relocsym(ctxt *Link, s *Symbol) { ...@@ -548,7 +548,7 @@ func relocsym(ctxt *Link, s *Symbol) {
o += Symaddr(rs) o += Symaddr(rs)
} }
} }
} else if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui { } else if Headtype == obj.Hwindows {
// nothing to do // nothing to do
} else { } else {
Errorf(s, "unhandled pcrel relocation to %s on %v", rs.Name, Headtype) Errorf(s, "unhandled pcrel relocation to %s on %v", rs.Name, Headtype)
...@@ -580,7 +580,7 @@ func relocsym(ctxt *Link, s *Symbol) { ...@@ -580,7 +580,7 @@ func relocsym(ctxt *Link, s *Symbol) {
// IMAGE_REL_I386_DIR32, IMAGE_REL_AMD64_ADDR64 and IMAGE_REL_AMD64_ADDR32. // IMAGE_REL_I386_DIR32, IMAGE_REL_AMD64_ADDR64 and IMAGE_REL_AMD64_ADDR32.
// Do not replace R_DWARFREF with R_ADDR for windows - // Do not replace R_DWARFREF with R_ADDR for windows -
// let PE code emit correct relocations. // let PE code emit correct relocations.
if Headtype != obj.Hwindows && Headtype != obj.Hwindowsgui { if Headtype != obj.Hwindows {
r.Type = obj.R_ADDR r.Type = obj.R_ADDR
} }
...@@ -659,7 +659,7 @@ func relocsym(ctxt *Link, s *Symbol) { ...@@ -659,7 +659,7 @@ func relocsym(ctxt *Link, s *Symbol) {
} else { } else {
o += int64(r.Siz) o += int64(r.Siz)
} }
} else if (Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui) && SysArch.Family == sys.AMD64 { // only amd64 needs PCREL } else if Headtype == obj.Hwindows && SysArch.Family == sys.AMD64 { // only amd64 needs PCREL
// PE/COFF's PC32 relocation uses the address after the relocated // PE/COFF's PC32 relocation uses the address after the relocated
// bytes as the base. Compensate by skewing the addend. // bytes as the base. Compensate by skewing the addend.
o += int64(r.Siz) o += int64(r.Siz)
...@@ -745,7 +745,7 @@ func (ctxt *Link) reloc() { ...@@ -745,7 +745,7 @@ func (ctxt *Link) reloc() {
} }
func dynrelocsym(ctxt *Link, s *Symbol) { func dynrelocsym(ctxt *Link, s *Symbol) {
if (Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui) && Linkmode != LinkExternal { if Headtype == obj.Hwindows && Linkmode != LinkExternal {
rel := ctxt.Syms.Lookup(".rel", 0) rel := ctxt.Syms.Lookup(".rel", 0)
if s == rel { if s == rel {
return return
...@@ -813,7 +813,7 @@ func dynrelocsym(ctxt *Link, s *Symbol) { ...@@ -813,7 +813,7 @@ func dynrelocsym(ctxt *Link, s *Symbol) {
func dynreloc(ctxt *Link, data *[obj.SXREF][]*Symbol) { func dynreloc(ctxt *Link, data *[obj.SXREF][]*Symbol) {
// -d suppresses dynamic loader format, so we may as well not // -d suppresses dynamic loader format, so we may as well not
// compute these sections or mark their symbols as reachable. // compute these sections or mark their symbols as reachable.
if *FlagD && Headtype != obj.Hwindows && Headtype != obj.Hwindowsgui { if *FlagD && Headtype != obj.Hwindows {
return return
} }
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog != 0 {
...@@ -2197,7 +2197,7 @@ func (ctxt *Link) address() { ...@@ -2197,7 +2197,7 @@ func (ctxt *Link) address() {
Segdata.Vaddr = va Segdata.Vaddr = va
Segdata.Fileoff = va - Segtext.Vaddr + Segtext.Fileoff Segdata.Fileoff = va - Segtext.Vaddr + Segtext.Fileoff
Segdata.Filelen = 0 Segdata.Filelen = 0
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui { if Headtype == obj.Hwindows {
Segdata.Fileoff = Segtext.Fileoff + uint64(Rnd(int64(Segtext.Length), PEFILEALIGN)) Segdata.Fileoff = Segtext.Fileoff + uint64(Rnd(int64(Segtext.Length), PEFILEALIGN))
} }
if Headtype == obj.Hplan9 { if Headtype == obj.Hplan9 {
...@@ -2240,7 +2240,7 @@ func (ctxt *Link) address() { ...@@ -2240,7 +2240,7 @@ func (ctxt *Link) address() {
Segdwarf.Vaddr = va Segdwarf.Vaddr = va
Segdwarf.Fileoff = Segdata.Fileoff + uint64(Rnd(int64(Segdata.Filelen), int64(*FlagRound))) Segdwarf.Fileoff = Segdata.Fileoff + uint64(Rnd(int64(Segdata.Filelen), int64(*FlagRound)))
Segdwarf.Filelen = 0 Segdwarf.Filelen = 0
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui { if Headtype == obj.Hwindows {
Segdwarf.Fileoff = Segdata.Fileoff + uint64(Rnd(int64(Segdata.Filelen), int64(PEFILEALIGN))) Segdwarf.Fileoff = Segdata.Fileoff + uint64(Rnd(int64(Segdata.Filelen), int64(PEFILEALIGN)))
} }
for s := Segdwarf.Sect; s != nil; s = s.Next { for s := Segdwarf.Sect; s != nil; s = s.Next {
...@@ -2250,7 +2250,7 @@ func (ctxt *Link) address() { ...@@ -2250,7 +2250,7 @@ func (ctxt *Link) address() {
} }
s.Vaddr = va s.Vaddr = va
va += uint64(vlen) va += uint64(vlen)
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui { if Headtype == obj.Hwindows {
va = uint64(Rnd(int64(va), PEFILEALIGN)) va = uint64(Rnd(int64(va), PEFILEALIGN))
} }
Segdwarf.Length = va - Segdwarf.Vaddr Segdwarf.Length = va - Segdwarf.Vaddr
......
...@@ -431,7 +431,7 @@ func (ctxt *Link) loadlib() { ...@@ -431,7 +431,7 @@ func (ctxt *Link) loadlib() {
determineLinkMode(ctxt) determineLinkMode(ctxt)
// Recalculate pe parameters now that we have Linkmode set. // Recalculate pe parameters now that we have Linkmode set.
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui { if Headtype == obj.Hwindows {
Peinit(ctxt) Peinit(ctxt)
} }
...@@ -573,7 +573,7 @@ func (ctxt *Link) loadlib() { ...@@ -573,7 +573,7 @@ func (ctxt *Link) loadlib() {
if *flagLibGCC != "none" { if *flagLibGCC != "none" {
hostArchive(ctxt, *flagLibGCC) hostArchive(ctxt, *flagLibGCC)
} }
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui { if Headtype == obj.Hwindows {
if p := ctxt.findLibPath("libmingwex.a"); p != "none" { if p := ctxt.findLibPath("libmingwex.a"); p != "none" {
hostArchive(ctxt, p) hostArchive(ctxt, p)
} }
...@@ -1213,7 +1213,7 @@ func (l *Link) hostlink() { ...@@ -1213,7 +1213,7 @@ func (l *Link) hostlink() {
} }
} }
} }
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui { if Headtype == obj.Hwindows {
// libmingw32 and libmingwex have some inter-dependencies, // libmingw32 and libmingwex have some inter-dependencies,
// so must use linker groups. // so must use linker groups.
argv = append(argv, "-Wl,--start-group", "-lmingwex", "-lmingw32", "-Wl,--end-group") argv = append(argv, "-Wl,--start-group", "-lmingwex", "-lmingw32", "-Wl,--end-group")
...@@ -1954,7 +1954,7 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, * ...@@ -1954,7 +1954,7 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, *
put(ctxt, nil, s.Name, FileSym, s.Value, nil) put(ctxt, nil, s.Name, FileSym, s.Value, nil)
case obj.SHOSTOBJ: case obj.SHOSTOBJ:
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui || Iself { if Headtype == obj.Hwindows || Iself {
put(ctxt, s, s.Name, UndefinedSym, s.Value, nil) put(ctxt, s, s.Name, UndefinedSym, s.Value, nil)
} }
......
...@@ -148,7 +148,7 @@ func Main() { ...@@ -148,7 +148,7 @@ func Main() {
if *flagOutfile == "" { if *flagOutfile == "" {
*flagOutfile = "a.out" *flagOutfile = "a.out"
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui { if Headtype == obj.Hwindows {
*flagOutfile += ".exe" *flagOutfile += ".exe"
} }
} }
...@@ -204,7 +204,7 @@ func Main() { ...@@ -204,7 +204,7 @@ func Main() {
ctxt.domacho() ctxt.domacho()
} }
ctxt.dostkcheck() ctxt.dostkcheck()
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui { if Headtype == obj.Hwindows {
ctxt.dope() ctxt.dope()
} }
ctxt.addexport() ctxt.addexport()
......
...@@ -63,7 +63,7 @@ func (ctxt *Link) computeTLSOffset() { ...@@ -63,7 +63,7 @@ func (ctxt *Link) computeTLSOffset() {
default: default:
log.Fatalf("unknown thread-local storage offset for %v", Headtype) log.Fatalf("unknown thread-local storage offset for %v", Headtype)
case obj.Hplan9, obj.Hwindows, obj.Hwindowsgui: case obj.Hplan9, obj.Hwindows:
break break
/* /*
......
...@@ -336,7 +336,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -336,7 +336,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
return true return true
} }
if (ld.Headtype == obj.Hwindows || ld.Headtype == obj.Hwindowsgui) && s.Size == int64(ld.SysArch.PtrSize) { if ld.Headtype == obj.Hwindows && s.Size == int64(ld.SysArch.PtrSize) {
// nothing to do, the relocation will be laid out in pereloc1 // nothing to do, the relocation will be laid out in pereloc1
return true return true
} }
...@@ -699,7 +699,7 @@ func asmb(ctxt *ld.Link) { ...@@ -699,7 +699,7 @@ func asmb(ctxt *ld.Link) {
case obj.Hdarwin: case obj.Hdarwin:
symo = uint32(ld.Segdwarf.Fileoff + uint64(ld.Rnd(int64(ld.Segdwarf.Filelen), int64(*ld.FlagRound))) + uint64(machlink)) symo = uint32(ld.Segdwarf.Fileoff + uint64(ld.Rnd(int64(ld.Segdwarf.Filelen), int64(*ld.FlagRound))) + uint64(machlink))
case obj.Hwindows, obj.Hwindowsgui: case obj.Hwindows:
symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen) symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = uint32(ld.Rnd(int64(symo), ld.PEFILEALIGN)) symo = uint32(ld.Rnd(int64(symo), ld.PEFILEALIGN))
} }
...@@ -734,7 +734,7 @@ func asmb(ctxt *ld.Link) { ...@@ -734,7 +734,7 @@ func asmb(ctxt *ld.Link) {
ld.Cflush() ld.Cflush()
} }
case obj.Hwindows, obj.Hwindowsgui: case obj.Hwindows:
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog != 0 {
ctxt.Logf("%5.2f dwarf\n", obj.Cputime()) ctxt.Logf("%5.2f dwarf\n", obj.Cputime())
} }
...@@ -774,7 +774,7 @@ func asmb(ctxt *ld.Link) { ...@@ -774,7 +774,7 @@ func asmb(ctxt *ld.Link) {
obj.Hnacl: obj.Hnacl:
ld.Asmbelf(ctxt, int64(symo)) ld.Asmbelf(ctxt, int64(symo))
case obj.Hwindows, obj.Hwindowsgui: case obj.Hwindows:
ld.Asmbpe(ctxt) ld.Asmbpe(ctxt)
} }
......
...@@ -133,7 +133,7 @@ func archinit(ctxt *ld.Link) { ...@@ -133,7 +133,7 @@ func archinit(ctxt *ld.Link) {
*ld.FlagRound = 0x10000 *ld.FlagRound = 0x10000
} }
case obj.Hwindows, obj.Hwindowsgui: /* PE executable */ case obj.Hwindows: /* PE executable */
// ld.HEADR, ld.FlagTextAddr, ld.FlagDataAddr and ld.FlagRound are set in ld.Peinit // ld.HEADR, ld.FlagTextAddr, ld.FlagDataAddr and ld.FlagRound are set in ld.Peinit
return return
} }
......
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