]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: move Headtype global to ctxt
authorDavid Crawshaw <crawshaw@golang.org>
Sat, 7 Oct 2017 17:49:44 +0000 (13:49 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Sat, 21 Oct 2017 00:51:14 +0000 (00:51 +0000)
For #22095

Change-Id: Idcfdfe8a94db8626392658bb93429454238f648a
Reviewed-on: https://go-review.googlesource.com/70835
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
27 files changed:
src/cmd/link/internal/amd64/asm.go
src/cmd/link/internal/amd64/obj.go
src/cmd/link/internal/arm/asm.go
src/cmd/link/internal/arm/obj.go
src/cmd/link/internal/arm64/asm.go
src/cmd/link/internal/arm64/obj.go
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/deadcode.go
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/elf.go
src/cmd/link/internal/ld/go.go
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/link.go
src/cmd/link/internal/ld/main.go
src/cmd/link/internal/ld/pcln.go
src/cmd/link/internal/ld/sym.go
src/cmd/link/internal/ld/symtab.go
src/cmd/link/internal/mips/asm.go
src/cmd/link/internal/mips/obj.go
src/cmd/link/internal/mips64/asm.go
src/cmd/link/internal/mips64/obj.go
src/cmd/link/internal/ppc64/asm.go
src/cmd/link/internal/ppc64/obj.go
src/cmd/link/internal/s390x/asm.go
src/cmd/link/internal/s390x/obj.go
src/cmd/link/internal/x86/asm.go
src/cmd/link/internal/x86/obj.go

index dde47ac7c5f25371ef13ef794eb7f6429e8e7244..ca652f835342bf40840d6d6e2de64d2950134069 100644 (file)
@@ -251,7 +251,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
 
        case objabi.R_ADDR:
                if s.Type == sym.STEXT && ctxt.IsELF {
-                       if ld.Headtype == objabi.Hsolaris {
+                       if ctxt.HeadType == objabi.Hsolaris {
                                addpltsym(ctxt, targ)
                                r.Sym = ctxt.Syms.Lookup(".plt", 0)
                                r.Add += int64(targ.Plt)
@@ -334,7 +334,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
                        return true
                }
 
-               if ld.Headtype == objabi.Hdarwin && s.Size == int64(ctxt.Arch.PtrSize) && r.Off == 0 {
+               if ctxt.HeadType == objabi.Hdarwin && s.Size == int64(ctxt.Arch.PtrSize) && r.Off == 0 {
                        // Mach-O relocations are a royal pain to lay out.
                        // They use a compact stateful bytecode representation
                        // that is too much bother to deal with.
@@ -603,7 +603,7 @@ func addpltsym(ctxt *ld.Link, s *sym.Symbol) {
                rela.AddUint64(ctxt.Arch, 0)
 
                s.Plt = int32(plt.Size - 16)
-       } else if ld.Headtype == objabi.Hdarwin {
+       } else if ctxt.HeadType == objabi.Hdarwin {
                // To do lazy symbol lookup right, we're supposed
                // to tell the dynamic loader which library each
                // symbol comes from and format the link info
@@ -645,7 +645,7 @@ func addgotsym(ctxt *ld.Link, s *sym.Symbol) {
                rela.AddAddrPlus(ctxt.Arch, got, int64(s.Got))
                rela.AddUint64(ctxt.Arch, ld.ELF64_R_INFO(uint32(s.Dynid), uint32(elf.R_X86_64_GLOB_DAT)))
                rela.AddUint64(ctxt.Arch, 0)
-       } else if ld.Headtype == objabi.Hdarwin {
+       } else if ctxt.HeadType == objabi.Hdarwin {
                ctxt.Syms.Lookup(".linkedit.got", 0).AddUint32(ctxt.Arch, uint32(s.Dynid))
        } else {
                ld.Errorf(s, "addgotsym: unsupported binary format")
@@ -700,13 +700,13 @@ func asmb(ctxt *ld.Link) {
        ld.Dwarfblk(ctxt, int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
 
        machlink := int64(0)
-       if ld.Headtype == objabi.Hdarwin {
+       if ctxt.HeadType == objabi.Hdarwin {
                machlink = ld.Domacholink(ctxt)
        }
 
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
-               ld.Errorf(nil, "unknown header type %v", ld.Headtype)
+               ld.Errorf(nil, "unknown header type %v", ctxt.HeadType)
                fallthrough
 
        case objabi.Hplan9:
@@ -736,7 +736,7 @@ func asmb(ctxt *ld.Link) {
                if ctxt.Debugvlog != 0 {
                        ctxt.Logf("%5.2f sym\n", ld.Cputime())
                }
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                case objabi.Hplan9:
                        *ld.FlagS = true
@@ -761,7 +761,7 @@ func asmb(ctxt *ld.Link) {
                }
 
                ctxt.Out.SeekSet(symo)
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                ctxt.Out.SeekSet(symo)
@@ -805,7 +805,7 @@ func asmb(ctxt *ld.Link) {
                ctxt.Logf("%5.2f headr\n", ld.Cputime())
        }
        ctxt.Out.SeekSet(0)
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
        case objabi.Hplan9: /* plan9 */
                magic := int32(4*26*26 + 7)
index c766512a0150fd5050a14b87d6bf8377901375b9..87e809166a330329d070df97422dd2d2ce03317d 100644 (file)
@@ -74,9 +74,9 @@ func Init() (*sys.Arch, ld.Arch) {
 }
 
 func archinit(ctxt *ld.Link) {
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
-               ld.Exitf("unknown -H option: %v", ld.Headtype)
+               ld.Exitf("unknown -H option: %v", ctxt.HeadType)
 
        case objabi.Hplan9: /* plan 9 */
                ld.HEADR = 32 + 8
index cbb97c3b6bc7e33f9593f0ca2d51f66ed95ef0a9..93c2a85690143ab72bab023f44c1c3c2487aa7cb 100644 (file)
@@ -590,7 +590,7 @@ func archreloc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val *int64) bool {
                        // the section load address.
                        // we need to compensate that by removing the instruction's address
                        // from addend.
-                       if ld.Headtype == objabi.Hdarwin {
+                       if ctxt.HeadType == objabi.Hdarwin {
                                r.Xadd -= ld.Symaddr(s) + int64(r.Off)
                        }
 
@@ -781,7 +781,7 @@ func asmb(ctxt *ld.Link) {
        ld.Dwarfblk(ctxt, int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
 
        machlink := uint32(0)
-       if ld.Headtype == objabi.Hdarwin {
+       if ctxt.HeadType == objabi.Hdarwin {
                machlink = uint32(ld.Domacholink(ctxt))
        }
 
@@ -795,7 +795,7 @@ func asmb(ctxt *ld.Link) {
                if ctxt.Debugvlog != 0 {
                        ctxt.Logf("%5.2f sym\n", ld.Cputime())
                }
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
@@ -810,7 +810,7 @@ func asmb(ctxt *ld.Link) {
                }
 
                ctxt.Out.SeekSet(int64(symo))
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                if ctxt.Debugvlog != 0 {
@@ -847,7 +847,7 @@ func asmb(ctxt *ld.Link) {
                ctxt.Logf("%5.2f header\n", ld.Cputime())
        }
        ctxt.Out.SeekSet(0)
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
        case objabi.Hplan9: /* plan 9 */
                ctxt.Out.Write32b(0x647)                      /* magic */
index a874a24e6c70a8f49ffdd76cb040e7b42b56ccc5..da16f923458b1bf1bde2d86c4bd04cab25f207fd 100644 (file)
@@ -70,9 +70,9 @@ func Init() (*sys.Arch, ld.Arch) {
 }
 
 func archinit(ctxt *ld.Link) {
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
-               ld.Exitf("unknown -H option: %v", ld.Headtype)
+               ld.Exitf("unknown -H option: %v", ctxt.HeadType)
 
        case objabi.Hplan9: /* plan 9 */
                ld.HEADR = 32
index cc7f4d1abf3599f6305c0f93f67c9fb37d7dd3c8..d8245590beaf40aa639d292adbb72d5c9cfaeafd 100644 (file)
@@ -273,7 +273,7 @@ func archreloc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val *int64) bool {
                        // the BR26 relocation should be fully resolved at link time.
                        // That is the reason why the next if block is disabled. When the bug in ld64
                        // is fixed, we can enable this block and also enable duff's device in cmd/7g.
-                       if false && ld.Headtype == objabi.Hdarwin {
+                       if false && ctxt.HeadType == objabi.Hdarwin {
                                var o0, o1 uint32
 
                                if ctxt.Arch.ByteOrder == binary.BigEndian {
@@ -346,8 +346,8 @@ func archreloc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val *int64) bool {
                return true
        case objabi.R_ARM64_TLS_LE:
                r.Done = false
-               if ld.Headtype != objabi.Hlinux {
-                       ld.Errorf(s, "TLS reloc on unsupported OS %v", ld.Headtype)
+               if ctxt.HeadType != objabi.Hlinux {
+                       ld.Errorf(s, "TLS reloc on unsupported OS %v", ctxt.HeadType)
                }
                // The TCB is two pointers. This is not documented anywhere, but is
                // de facto part of the ABI.
@@ -417,7 +417,7 @@ func asmb(ctxt *ld.Link) {
        ld.Dwarfblk(ctxt, int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
 
        machlink := uint32(0)
-       if ld.Headtype == objabi.Hdarwin {
+       if ctxt.HeadType == objabi.Hdarwin {
                machlink = uint32(ld.Domacholink(ctxt))
        }
 
@@ -431,7 +431,7 @@ func asmb(ctxt *ld.Link) {
                if ctxt.Debugvlog != 0 {
                        ctxt.Logf("%5.2f sym\n", ld.Cputime())
                }
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
@@ -446,7 +446,7 @@ func asmb(ctxt *ld.Link) {
                }
 
                ctxt.Out.SeekSet(int64(symo))
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                if ctxt.Debugvlog != 0 {
@@ -483,7 +483,7 @@ func asmb(ctxt *ld.Link) {
                ctxt.Logf("%5.2f header\n", ld.Cputime())
        }
        ctxt.Out.SeekSet(0)
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
        case objabi.Hplan9: /* plan 9 */
                ctxt.Out.Write32(0x647)                      /* magic */
index 225cfbd294662a5e88fff2873fe5831cdc45197d..6b386ad73790320c60c08972adfa5d151e7efe23 100644 (file)
@@ -70,9 +70,9 @@ func Init() (*sys.Arch, ld.Arch) {
 }
 
 func archinit(ctxt *ld.Link) {
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
-               ld.Exitf("unknown -H option: %v", ld.Headtype)
+               ld.Exitf("unknown -H option: %v", ctxt.HeadType)
 
        case objabi.Hplan9: /* plan 9 */
                ld.HEADR = 32
index 11bdf9ce41098519f8bfc065cfb1271cf77364da..cb824811aa1d7af5f8bb1ac91bd61002a5a7313d 100644 (file)
@@ -148,7 +148,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
 
                // We need to be able to reference dynimport symbols when linking against
                // shared libraries, and Solaris needs it always
-               if Headtype != objabi.Hsolaris && r.Sym != nil && r.Sym.Type == sym.SDYNIMPORT && !ctxt.DynlinkingGo() {
+               if ctxt.HeadType != objabi.Hsolaris && r.Sym != nil && r.Sym.Type == sym.SDYNIMPORT && !ctxt.DynlinkingGo() {
                        if !(ctxt.Arch.Family == sys.PPC64 && ctxt.LinkMode == LinkExternal && r.Sym.Name == ".TOC.") {
                                Errorf(s, "unhandled relocation for %s (type %d (%s) rtype %d (%s))", r.Sym.Name, r.Sym.Type, r.Sym.Type, r.Type, sym.RelocName(ctxt.Arch, r.Type))
                        }
@@ -212,12 +212,12 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                                // related to the fact that our own TLS storage happens
                                // to take up 8 bytes.
                                o = 8 + r.Sym.Value
-                       } else if ctxt.IsELF || Headtype == objabi.Hplan9 || Headtype == objabi.Hdarwin || isAndroidX86 {
+                       } else if ctxt.IsELF || ctxt.HeadType == objabi.Hplan9 || ctxt.HeadType == objabi.Hdarwin || isAndroidX86 {
                                o = int64(ctxt.Tlsoffset) + r.Add
-                       } else if Headtype == objabi.Hwindows {
+                       } else if ctxt.HeadType == objabi.Hwindows {
                                o = r.Add
                        } else {
-                               log.Fatalf("unexpected R_TLS_LE relocation for %v", Headtype)
+                               log.Fatalf("unexpected R_TLS_LE relocation for %v", ctxt.HeadType)
                        }
                case objabi.R_TLS_IE:
                        isAndroidX86 := objabi.GOOS == "android" && (ctxt.Arch.InFamily(sys.AMD64, sys.I386))
@@ -272,7 +272,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                                        if ctxt.Arch.Family == sys.AMD64 {
                                                o = 0
                                        }
-                               } else if Headtype == objabi.Hdarwin {
+                               } else if ctxt.HeadType == objabi.Hdarwin {
                                        // ld64 for arm64 has a bug where if the address pointed to by o exists in the
                                        // symbol table (dynid >= 0), or is inside a symbol that exists in the symbol
                                        // table, then it will add o twice into the relocated value.
@@ -286,10 +286,10 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                                                        o += Symaddr(rs)
                                                }
                                        }
-                               } else if Headtype == objabi.Hwindows {
+                               } else if ctxt.HeadType == objabi.Hwindows {
                                        // nothing to do
                                } else {
-                                       Errorf(s, "unhandled pcrel relocation to %s on %v", rs.Name, Headtype)
+                                       Errorf(s, "unhandled pcrel relocation to %s on %v", rs.Name, ctxt.HeadType)
                                }
 
                                break
@@ -319,7 +319,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                                // DWARF linking, and it understands how to follow section offsets.
                                // Leaving in the relocation records confuses it (see
                                // https://golang.org/issue/22068) so drop them for Darwin.
-                               if Headtype == objabi.Hdarwin {
+                               if ctxt.HeadType == objabi.Hdarwin {
                                        r.Done = true
                                }
 
@@ -328,7 +328,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                                // IMAGE_REL_I386_DIR32, IMAGE_REL_AMD64_ADDR64 and IMAGE_REL_AMD64_ADDR32.
                                // Do not replace R_DWARFREF with R_ADDR for windows -
                                // let PE code emit correct relocations.
-                               if Headtype != objabi.Hwindows {
+                               if ctxt.HeadType != objabi.Hwindows {
                                        r.Type = objabi.R_ADDR
                                }
 
@@ -359,7 +359,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
 
                        // r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call.
                case objabi.R_GOTPCREL:
-                       if ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin && r.Sym != nil && r.Sym.Type != sym.SCONST {
+                       if ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin && r.Sym != nil && r.Sym.Type != sym.SCONST {
                                r.Done = false
                                r.Xadd = r.Add
                                r.Xadd -= int64(r.Siz) // relative to address after the relocated chunk
@@ -394,7 +394,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                                        if ctxt.Arch.Family == sys.AMD64 {
                                                o = 0
                                        }
-                               } else if Headtype == objabi.Hdarwin {
+                               } else if ctxt.HeadType == objabi.Hdarwin {
                                        if r.Type == objabi.R_CALL {
                                                if rs.Type != sym.SHOSTOBJ {
                                                        o += int64(uint64(Symaddr(rs)) - rs.Sect.Vaddr)
@@ -406,12 +406,12 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                                        } else {
                                                o += int64(r.Siz)
                                        }
-                               } else if Headtype == objabi.Hwindows && ctxt.Arch.Family == sys.AMD64 { // only amd64 needs PCREL
+                               } else if ctxt.HeadType == objabi.Hwindows && ctxt.Arch.Family == sys.AMD64 { // only amd64 needs PCREL
                                        // PE/COFF's PC32 relocation uses the address after the relocated
                                        // bytes as the base. Compensate by skewing the addend.
                                        o += int64(r.Siz)
                                } else {
-                                       Errorf(s, "unhandled pcrel relocation to %s on %v", rs.Name, Headtype)
+                                       Errorf(s, "unhandled pcrel relocation to %s on %v", rs.Name, ctxt.HeadType)
                                }
 
                                break
@@ -531,7 +531,7 @@ func windynrelocsym(ctxt *Link, s *sym.Symbol) {
 }
 
 func dynrelocsym(ctxt *Link, s *sym.Symbol) {
-       if Headtype == objabi.Hwindows {
+       if ctxt.HeadType == objabi.Hwindows {
                if ctxt.LinkMode == LinkInternal {
                        windynrelocsym(ctxt, s)
                }
@@ -561,7 +561,7 @@ func dynrelocsym(ctxt *Link, s *sym.Symbol) {
 func dynreloc(ctxt *Link, data *[sym.SXREF][]*sym.Symbol) {
        // -d suppresses dynamic loader format, so we may as well not
        // compute these sections or mark their symbols as reachable.
-       if *FlagD && Headtype != objabi.Hwindows {
+       if *FlagD && ctxt.HeadType != objabi.Hwindows {
                return
        }
        if ctxt.Debugvlog != 0 {
@@ -1009,7 +1009,7 @@ func (ctxt *Link) dodata() {
                ctxt.Logf("%5.2f dodata\n", Cputime())
        }
 
-       if ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin {
+       if ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin {
                // The values in moduledata are filled out by relocations
                // pointing to the addresses of these special symbols.
                // Typically these symbols have no size and are not laid
@@ -1067,7 +1067,7 @@ func (ctxt *Link) dodata() {
        // symbol, which is itself data.
        //
        // On darwin, we need the symbol table numbers for dynreloc.
-       if Headtype == objabi.Hdarwin {
+       if ctxt.HeadType == objabi.Hdarwin {
                machosymorder(ctxt)
        }
        dynreloc(ctxt, &data)
@@ -1612,7 +1612,7 @@ func (ctxt *Link) dodata() {
 }
 
 func dodataSect(ctxt *Link, symn sym.SymKind, syms []*sym.Symbol) (result []*sym.Symbol, maxAlign int32) {
-       if Headtype == objabi.Hdarwin {
+       if ctxt.HeadType == objabi.Hdarwin {
                // Some symbols may no longer belong in syms
                // due to movement in machosymorder.
                newSyms := make([]*sym.Symbol, 0, len(syms))
@@ -1643,7 +1643,7 @@ func dodataSect(ctxt *Link, symn sym.SymKind, syms []*sym.Symbol) (result []*sym
                // If the usually-special section-marker symbols are being laid
                // out as regular symbols, put them either at the beginning or
                // end of their section.
-               if ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin {
+               if ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin {
                        switch s.Name {
                        case "runtime.text", "runtime.bss", "runtime.data", "runtime.types":
                                head = s
@@ -1764,7 +1764,7 @@ func (ctxt *Link) textaddress() {
        text := ctxt.Syms.Lookup("runtime.text", 0)
        text.Sect = sect
 
-       if ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin {
+       if ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin {
                etext := ctxt.Syms.Lookup("runtime.etext", 0)
                etext.Sect = sect
 
@@ -1873,7 +1873,7 @@ func (ctxt *Link) address() {
 
        Segtext.Length = va - uint64(*FlagTextAddr)
        Segtext.Filelen = Segtext.Length
-       if Headtype == objabi.Hnacl {
+       if ctxt.HeadType == objabi.Hnacl {
                va += 32 // room for the "halt sled"
        }
 
@@ -1930,10 +1930,10 @@ func (ctxt *Link) address() {
        Segdata.Vaddr = va
        Segdata.Fileoff = va - Segtext.Vaddr + Segtext.Fileoff
        Segdata.Filelen = 0
-       if Headtype == objabi.Hwindows {
+       if ctxt.HeadType == objabi.Hwindows {
                Segdata.Fileoff = Segtext.Fileoff + uint64(Rnd(int64(Segtext.Length), PEFILEALIGN))
        }
-       if Headtype == objabi.Hplan9 {
+       if ctxt.HeadType == objabi.Hplan9 {
                Segdata.Fileoff = Segtext.Fileoff + Segtext.Filelen
        }
        var data *sym.Section
@@ -1972,7 +1972,7 @@ func (ctxt *Link) address() {
        Segdwarf.Vaddr = va
        Segdwarf.Fileoff = Segdata.Fileoff + uint64(Rnd(int64(Segdata.Filelen), int64(*FlagRound)))
        Segdwarf.Filelen = 0
-       if Headtype == objabi.Hwindows {
+       if ctxt.HeadType == objabi.Hwindows {
                Segdwarf.Fileoff = Segdata.Fileoff + uint64(Rnd(int64(Segdata.Filelen), int64(PEFILEALIGN)))
        }
        for i, s := range Segdwarf.Sections {
@@ -1982,7 +1982,7 @@ func (ctxt *Link) address() {
                }
                s.Vaddr = va
                va += uint64(vlen)
-               if Headtype == objabi.Hwindows {
+               if ctxt.HeadType == objabi.Hwindows {
                        va = uint64(Rnd(int64(va), PEFILEALIGN))
                }
                Segdwarf.Length = va - Segdwarf.Vaddr
index 99e7789ad58b67adc8e778d84e035efc5df80a6b..c065146fcd28684a37761b546137c9cb27be5524 100644 (file)
@@ -222,7 +222,7 @@ func (d *deadcodepass) init() {
                } else {
                        // The external linker refers main symbol directly.
                        if d.ctxt.LinkMode == LinkExternal && (d.ctxt.BuildMode == BuildModeExe || d.ctxt.BuildMode == BuildModePIE) {
-                               if Headtype == objabi.Hwindows && d.ctxt.Arch.Family == sys.I386 {
+                               if d.ctxt.HeadType == objabi.Hwindows && d.ctxt.Arch.Family == sys.I386 {
                                        *flagEntrySymbol = "_main"
                                } else {
                                        *flagEntrySymbol = "main"
index f4987bd23ac59e28a7dcd60591f34d6a056c1cbd..df19e8276059262f5d2cb15ac7b087140f561350 100644 (file)
@@ -1463,7 +1463,7 @@ func writepub(ctxt *Link, sname string, ispub func(*dwarf.DWDie) bool, syms []*s
 }
 
 func writegdbscript(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
-       if ctxt.LinkMode == LinkExternal && Headtype == objabi.Hwindows && ctxt.BuildMode == BuildModeCArchive {
+       if ctxt.LinkMode == LinkExternal && ctxt.HeadType == objabi.Hwindows && ctxt.BuildMode == BuildModeCArchive {
                // gcc on Windows places .debug_gdb_scripts in the wrong location, which
                // causes the program not to run. See https://golang.org/issue/20183
                // Non c-archives can avoid this issue via a linker script
@@ -1499,18 +1499,18 @@ func dwarfgeneratedebugsyms(ctxt *Link) {
        if *FlagW { // disable dwarf
                return
        }
-       if *FlagS && Headtype != objabi.Hdarwin {
+       if *FlagS && ctxt.HeadType != objabi.Hdarwin {
                return
        }
-       if Headtype == objabi.Hplan9 {
+       if ctxt.HeadType == objabi.Hplan9 {
                return
        }
 
        if ctxt.LinkMode == LinkExternal {
                switch {
                case ctxt.IsELF:
-               case Headtype == objabi.Hdarwin:
-               case Headtype == objabi.Hwindows:
+               case ctxt.HeadType == objabi.Hdarwin:
+               case ctxt.HeadType == objabi.Hwindows:
                default:
                        return
                }
index 4f7162f9affb40120494596b63372527acb93afe..230b0aa5df18bb1d4f96b37ebaae62946b3a380b 100644 (file)
@@ -516,7 +516,7 @@ func Elfinit(ctxt *Link) {
        case sys.ARM, sys.MIPS:
                if ctxt.Arch.Family == sys.ARM {
                        // we use EABI on linux/arm, freebsd/arm, netbsd/arm.
-                       if Headtype == objabi.Hlinux || Headtype == objabi.Hfreebsd || Headtype == objabi.Hnetbsd {
+                       if ctxt.HeadType == objabi.Hlinux || ctxt.HeadType == objabi.Hfreebsd || ctxt.HeadType == objabi.Hnetbsd {
                                // We set a value here that makes no indication of which
                                // float ABI the object uses, because this is information
                                // used by the dynamic linker to compare executables and
@@ -1450,10 +1450,10 @@ func (ctxt *Link) doelf() {
        if !*FlagD || ctxt.LinkMode == LinkExternal {
                Addstring(shstrtab, ".tbss")
        }
-       if Headtype == objabi.Hnetbsd {
+       if ctxt.HeadType == objabi.Hnetbsd {
                Addstring(shstrtab, ".note.netbsd.ident")
        }
-       if Headtype == objabi.Hopenbsd {
+       if ctxt.HeadType == objabi.Hopenbsd {
                Addstring(shstrtab, ".note.openbsd.ident")
        }
        if len(buildinfo) > 0 {
@@ -1826,7 +1826,7 @@ func Asmbelf(ctxt *Link, symo int64) {
         * segment boundaries downwards to include it.
         * Except on NaCl where it must not be loaded.
         */
-       if Headtype != objabi.Hnacl {
+       if ctxt.HeadType != objabi.Hnacl {
                o := int64(Segtext.Vaddr - pph.vaddr)
                Segtext.Vaddr -= uint64(o)
                Segtext.Length += uint64(o)
@@ -1843,7 +1843,7 @@ func Asmbelf(ctxt *Link, symo int64) {
                sh.flags = SHF_ALLOC
                sh.addralign = 1
                if interpreter == "" {
-                       switch Headtype {
+                       switch ctxt.HeadType {
                        case objabi.Hlinux:
                                interpreter = Thearch.Linuxdynld
 
@@ -1873,9 +1873,9 @@ func Asmbelf(ctxt *Link, symo int64) {
        }
 
        pnote = nil
-       if Headtype == objabi.Hnetbsd || Headtype == objabi.Hopenbsd {
+       if ctxt.HeadType == objabi.Hnetbsd || ctxt.HeadType == objabi.Hopenbsd {
                var sh *ElfShdr
-               switch Headtype {
+               switch ctxt.HeadType {
                case objabi.Hnetbsd:
                        sh = elfshname(".note.netbsd.ident")
                        resoff -= int64(elfnetbsdsig(sh, uint64(startva), uint64(resoff)))
@@ -2087,7 +2087,7 @@ func Asmbelf(ctxt *Link, symo int64) {
                }
        }
 
-       if Headtype == objabi.Hlinux {
+       if ctxt.HeadType == objabi.Hlinux {
                ph := newElfPhdr()
                ph.type_ = PT_GNU_STACK
                ph.flags = PF_W + PF_R
@@ -2097,7 +2097,7 @@ func Asmbelf(ctxt *Link, symo int64) {
                ph.type_ = PT_PAX_FLAGS
                ph.flags = 0x2a00 // mprotect, randexec, emutramp disabled
                ph.align = uint64(ctxt.Arch.RegSize)
-       } else if Headtype == objabi.Hsolaris {
+       } else if ctxt.HeadType == objabi.Hsolaris {
                ph := newElfPhdr()
                ph.type_ = PT_SUNWSTACK
                ph.flags = PF_W + PF_R
@@ -2181,13 +2181,13 @@ elfobj:
        eh.ident[EI_MAG1] = 'E'
        eh.ident[EI_MAG2] = 'L'
        eh.ident[EI_MAG3] = 'F'
-       if Headtype == objabi.Hfreebsd {
+       if ctxt.HeadType == objabi.Hfreebsd {
                eh.ident[EI_OSABI] = ELFOSABI_FREEBSD
-       } else if Headtype == objabi.Hnetbsd {
+       } else if ctxt.HeadType == objabi.Hnetbsd {
                eh.ident[EI_OSABI] = ELFOSABI_NETBSD
-       } else if Headtype == objabi.Hopenbsd {
+       } else if ctxt.HeadType == objabi.Hopenbsd {
                eh.ident[EI_OSABI] = ELFOSABI_OPENBSD
-       } else if Headtype == objabi.Hdragonfly {
+       } else if ctxt.HeadType == objabi.Hdragonfly {
                eh.ident[EI_OSABI] = ELFOSABI_NONE
        }
        if elf64 {
@@ -2230,10 +2230,10 @@ elfobj:
                a += int64(elfwriteinterp(ctxt.Out))
        }
        if ctxt.LinkMode != LinkExternal {
-               if Headtype == objabi.Hnetbsd {
+               if ctxt.HeadType == objabi.Hnetbsd {
                        a += int64(elfwritenetbsdsig(ctxt.Out))
                }
-               if Headtype == objabi.Hopenbsd {
+               if ctxt.HeadType == objabi.Hopenbsd {
                        a += int64(elfwriteopenbsdsig(ctxt.Out))
                }
                if len(buildinfo) > 0 {
index c4e6bf6f2f1b0d2785a9942308843961edf5b37c..6cfbaebb73c05500349d45e7458c64460d036cb0 100644 (file)
@@ -171,7 +171,7 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) {
                                // to force a link of foo.so.
                                havedynamic = 1
 
-                               if Headtype == objabi.Hdarwin {
+                               if ctxt.HeadType == objabi.Hdarwin {
                                        machoadddynlib(lib, ctxt.LinkMode)
                                } else {
                                        dynlib = append(dynlib, lib)
@@ -316,9 +316,9 @@ func Adddynsym(ctxt *Link, s *sym.Symbol) {
 
        if ctxt.IsELF {
                elfadddynsym(ctxt, s)
-       } else if Headtype == objabi.Hdarwin {
+       } else if ctxt.HeadType == objabi.Hdarwin {
                Errorf(s, "adddynsym: missed symbol (Extname=%s)", s.Extname)
-       } else if Headtype == objabi.Hwindows {
+       } else if ctxt.HeadType == objabi.Hwindows {
                // already taken care of
        } else {
                Errorf(s, "adddynsym: unsupported binary format")
@@ -358,7 +358,7 @@ func fieldtrack(ctxt *Link) {
 }
 
 func (ctxt *Link) addexport() {
-       if Headtype == objabi.Hdarwin {
+       if ctxt.HeadType == objabi.Hdarwin {
                return
        }
 
index 913b70ec9377b434eeedcd9384b6e27fdbe482a6..bd3abbba0a5698684ef748aeb52be5928ac80afc 100644 (file)
@@ -170,9 +170,8 @@ var (
        elfglobalsymndx int
        interpreter     string
 
-       debug_s  bool // backup old value of debug['s']
-       HEADR    int32
-       Headtype objabi.HeadType
+       debug_s bool // backup old value of debug['s']
+       HEADR   int32
 
        nerrors  int
        liveness int64
@@ -382,11 +381,11 @@ func (ctxt *Link) loadlib() {
        determineLinkMode(ctxt)
 
        // Recalculate pe parameters now that we have ctxt.LinkMode set.
-       if Headtype == objabi.Hwindows {
+       if ctxt.HeadType == objabi.Hwindows {
                Peinit(ctxt)
        }
 
-       if Headtype == objabi.Hdarwin && ctxt.LinkMode == LinkExternal {
+       if ctxt.HeadType == objabi.Hdarwin && ctxt.LinkMode == LinkExternal {
                *FlagTextAddr = 0
        }
 
@@ -522,7 +521,7 @@ func (ctxt *Link) loadlib() {
                        if *flagLibGCC != "none" {
                                hostArchive(ctxt, *flagLibGCC)
                        }
-                       if Headtype == objabi.Hwindows {
+                       if ctxt.HeadType == objabi.Hwindows {
                                if p := ctxt.findLibPath("libmingwex.a"); p != "none" {
                                        hostArchive(ctxt, p)
                                }
@@ -557,7 +556,7 @@ func (ctxt *Link) loadlib() {
        // Also leave it enabled on Solaris which doesn't support
        // statically linked binaries.
        if ctxt.BuildMode == BuildModeExe {
-               if havedynamic == 0 && Headtype != objabi.Hdarwin && Headtype != objabi.Hsolaris {
+               if havedynamic == 0 && ctxt.HeadType != objabi.Hdarwin && ctxt.HeadType != objabi.Hsolaris {
                        *FlagD = true
                }
        }
@@ -594,7 +593,7 @@ func (ctxt *Link) loadlib() {
        }
 
        if ctxt.Arch == sys.Arch386 {
-               if (ctxt.BuildMode == BuildModeCArchive && ctxt.IsELF) || (ctxt.BuildMode == BuildModeCShared && Headtype != objabi.Hwindows) || ctxt.BuildMode == BuildModePIE || ctxt.DynlinkingGo() {
+               if (ctxt.BuildMode == BuildModeCArchive && ctxt.IsELF) || (ctxt.BuildMode == BuildModeCShared && ctxt.HeadType != objabi.Hwindows) || ctxt.BuildMode == BuildModePIE || ctxt.DynlinkingGo() {
                        got := ctxt.Syms.Lookup("_GLOBAL_OFFSET_TABLE_", 0)
                        got.Type = sym.SDYNIMPORT
                        got.Attr |= sym.AttrReachable
@@ -866,7 +865,7 @@ var internalpkg = []string{
        "runtime/msan",
 }
 
-func ldhostobj(ld func(*Link, *bio.Reader, string, int64, string), f *bio.Reader, pkg string, length int64, pn string, file string) *Hostobj {
+func ldhostobj(ld func(*Link, *bio.Reader, string, int64, string), headType objabi.HeadType, f *bio.Reader, pkg string, length int64, pn string, file string) *Hostobj {
        isinternal := false
        for i := 0; i < len(internalpkg); i++ {
                if pkg == internalpkg[i] {
@@ -881,7 +880,7 @@ func ldhostobj(ld func(*Link, *bio.Reader, string, int64, string), f *bio.Reader
        // force external linking for any libraries that link in code that
        // uses errno. This can be removed if the Go linker ever supports
        // these relocation types.
-       if Headtype == objabi.Hdragonfly {
+       if headType == objabi.Hdragonfly {
                if pkg == "net" || pkg == "os/user" {
                        isinternal = false
                }
@@ -1076,7 +1075,7 @@ func (ctxt *Link) hostlink() {
 
        if !*FlagS && !debug_s {
                argv = append(argv, "-gdwarf-2")
-       } else if Headtype == objabi.Hdarwin {
+       } else if ctxt.HeadType == objabi.Hdarwin {
                // Recent versions of macOS print
                //      ld: warning: option -s is obsolete and being ignored
                // so do not pass any arguments.
@@ -1084,7 +1083,7 @@ func (ctxt *Link) hostlink() {
                argv = append(argv, "-s")
        }
 
-       switch Headtype {
+       switch ctxt.HeadType {
        case objabi.Hdarwin:
                argv = append(argv, "-Wl,-headerpad,1144")
                if ctxt.DynlinkingGo() {
@@ -1105,19 +1104,19 @@ func (ctxt *Link) hostlink() {
 
        switch ctxt.BuildMode {
        case BuildModeExe:
-               if Headtype == objabi.Hdarwin {
+               if ctxt.HeadType == objabi.Hdarwin {
                        argv = append(argv, "-Wl,-pagezero_size,4000000")
                }
        case BuildModePIE:
                // ELF.
-               if Headtype != objabi.Hdarwin {
+               if ctxt.HeadType != objabi.Hdarwin {
                        if ctxt.UseRelro() {
                                argv = append(argv, "-Wl,-z,relro")
                        }
                        argv = append(argv, "-pie")
                }
        case BuildModeCShared:
-               if Headtype == objabi.Hdarwin {
+               if ctxt.HeadType == objabi.Hdarwin {
                        argv = append(argv, "-dynamiclib")
                        if ctxt.Arch.Family != sys.AMD64 {
                                argv = append(argv, "-Wl,-read_only_relocs,suppress")
@@ -1129,7 +1128,7 @@ func (ctxt *Link) hostlink() {
                                argv = append(argv, "-Wl,-z,relro")
                        }
                        argv = append(argv, "-shared")
-                       if Headtype != objabi.Hwindows {
+                       if ctxt.HeadType != objabi.Hwindows {
                                // Pass -z nodelete to mark the shared library as
                                // non-closeable: a dlclose will do nothing.
                                argv = append(argv, "-Wl,-z,nodelete")
@@ -1141,7 +1140,7 @@ func (ctxt *Link) hostlink() {
                }
                argv = append(argv, "-shared")
        case BuildModePlugin:
-               if Headtype == objabi.Hdarwin {
+               if ctxt.HeadType == objabi.Hdarwin {
                        argv = append(argv, "-dynamiclib")
                } else {
                        if ctxt.UseRelro() {
@@ -1299,7 +1298,7 @@ func (ctxt *Link) hostlink() {
                        }
                }
        }
-       if Headtype == objabi.Hwindows {
+       if ctxt.HeadType == objabi.Hwindows {
                // use gcc linker script to work around gcc bug
                // (see https://golang.org/issue/20183 for details).
                p := writeGDBLinkerScript()
@@ -1326,7 +1325,7 @@ func (ctxt *Link) hostlink() {
                ctxt.Logf("%s", out)
        }
 
-       if !*FlagS && !*FlagW && !debug_s && Headtype == objabi.Hdarwin {
+       if !*FlagS && !*FlagW && !debug_s && ctxt.HeadType == objabi.Hdarwin {
                // Skip combining dwarf on arm.
                if !ctxt.Arch.InFamily(sys.ARM, sys.ARM64) {
                        dsym := filepath.Join(*flagTmpdir, "go.dwarf")
@@ -1395,7 +1394,7 @@ func ldobj(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, pn string,
                        ehdr.flags = flags
                        ctxt.Textp = append(ctxt.Textp, textp...)
                }
-               return ldhostobj(ldelf, f, pkg, length, pn, file)
+               return ldhostobj(ldelf, ctxt.HeadType, f, pkg, length, pn, file)
        }
 
        if magic&^1 == 0xfeedface || magic&^0x01000000 == 0xcefaedfe {
@@ -1407,7 +1406,7 @@ func ldobj(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, pn string,
                        }
                        ctxt.Textp = append(ctxt.Textp, textp...)
                }
-               return ldhostobj(ldmacho, f, pkg, length, pn, file)
+               return ldhostobj(ldmacho, ctxt.HeadType, f, pkg, length, pn, file)
        }
 
        if c1 == 0x4c && c2 == 0x01 || c1 == 0x64 && c2 == 0x86 {
@@ -1422,7 +1421,7 @@ func ldobj(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, pn string,
                        }
                        ctxt.Textp = append(ctxt.Textp, textp...)
                }
-               return ldhostobj(ldpe, f, pkg, length, pn, file)
+               return ldhostobj(ldpe, ctxt.HeadType, f, pkg, length, pn, file)
        }
 
        /* check the header */
@@ -1959,9 +1958,9 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
        s := ctxt.Syms.Lookup("runtime.text", 0)
        if s.Type == sym.STEXT {
                // We've already included this symbol in ctxt.Textp
-               // if ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin.
+               // if ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin.
                // See data.go:/textaddress
-               if !(ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin) {
+               if !(ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin) {
                        put(ctxt, s, s.Name, TextSym, s.Value, nil)
                }
        }
@@ -1990,9 +1989,9 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
        s = ctxt.Syms.Lookup("runtime.etext", 0)
        if s.Type == sym.STEXT {
                // We've already included this symbol in ctxt.Textp
-               // if ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin.
+               // if ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin.
                // See data.go:/textaddress
-               if !(ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin) {
+               if !(ctxt.DynlinkingGo() && ctxt.HeadType == objabi.Hdarwin) {
                        put(ctxt, s, s.Name, TextSym, s.Value, nil)
                }
        }
@@ -2043,7 +2042,7 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
                        put(ctxt, s, s.Name, BSSSym, Symaddr(s), s.Gotype)
 
                case sym.SHOSTOBJ:
-                       if Headtype == objabi.Hwindows || ctxt.IsELF {
+                       if ctxt.HeadType == objabi.Hwindows || ctxt.IsELF {
                                put(ctxt, s, s.Name, UndefinedSym, s.Value, nil)
                        }
 
index 65afd49db963c75ab49c957220762d163aea05ae..a413353b9fb56c148cc9de9c3d5a1438d5659a97 100644 (file)
@@ -60,7 +60,8 @@ type Link struct {
 
        Loaded bool // set after all inputs have been loaded as symbols
 
-       IsELF bool
+       IsELF    bool
+       HeadType objabi.HeadType
 
        linkShared bool // link against installed Go shared libraries
        LinkMode   LinkMode
index 8c69d297c088a2a912ccb034878ff05826296a4d..42e1ef7f47235907fe04a88c359e78ed41555c87 100644 (file)
@@ -85,7 +85,6 @@ 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`")
@@ -115,6 +114,7 @@ func Main(arch *sys.Arch, theArch Arch) {
        if ctxt.Arch.Family == sys.AMD64 && objabi.GOOS == "plan9" {
                flag.BoolVar(&Flag8, "8", false, "use 64-bit addresses in symbol table")
        }
+       flagHeadType := flag.String("H", "", "set header `type`")
        flag.BoolVar(&ctxt.linkShared, "linkshared", false, "link against installed Go shared libraries")
        flag.Var(&ctxt.LinkMode, "linkmode", "set link `mode`")
        flag.Var(&ctxt.BuildMode, "buildmode", "set build `mode`")
@@ -127,13 +127,13 @@ func Main(arch *sys.Arch, theArch Arch) {
 
        objabi.Flagparse(usage)
 
-       switch *flagHeadtype {
+       switch *flagHeadType {
        case "":
        case "windowsgui":
-               Headtype = objabi.Hwindows
+               ctxt.HeadType = objabi.Hwindows
                windowsgui = true
        default:
-               if err := Headtype.Set(*flagHeadtype); err != nil {
+               if err := ctxt.HeadType.Set(*flagHeadType); err != nil {
                        Errorf(nil, "%v", err)
                        usage()
                }
@@ -150,7 +150,7 @@ func Main(arch *sys.Arch, theArch Arch) {
 
        if *flagOutfile == "" {
                *flagOutfile = "a.out"
-               if Headtype == objabi.Hwindows {
+               if ctxt.HeadType == objabi.Hwindows {
                        *flagOutfile += ".exe"
                }
        }
@@ -159,8 +159,8 @@ func Main(arch *sys.Arch, theArch Arch) {
 
        libinit(ctxt) // creates outfile
 
-       if Headtype == objabi.Hunknown {
-               Headtype.Set(objabi.GOOS)
+       if ctxt.HeadType == objabi.Hunknown {
+               ctxt.HeadType.Set(objabi.GOOS)
        }
 
        ctxt.computeTLSOffset()
@@ -171,7 +171,7 @@ func Main(arch *sys.Arch, theArch Arch) {
        }
 
        if ctxt.Debugvlog != 0 {
-               ctxt.Logf("HEADER = -H%d -T0x%x -D0x%x -R0x%x\n", Headtype, uint64(*FlagTextAddr), uint64(*FlagDataAddr), uint32(*FlagRound))
+               ctxt.Logf("HEADER = -H%d -T0x%x -D0x%x -R0x%x\n", ctxt.HeadType, uint64(*FlagTextAddr), uint64(*FlagDataAddr), uint32(*FlagRound))
        }
 
        switch ctxt.BuildMode {
@@ -202,11 +202,11 @@ func Main(arch *sys.Arch, theArch Arch) {
        ctxt.callgraph()
 
        ctxt.doelf()
-       if Headtype == objabi.Hdarwin {
+       if ctxt.HeadType == objabi.Hdarwin {
                ctxt.domacho()
        }
        ctxt.dostkcheck()
-       if Headtype == objabi.Hwindows {
+       if ctxt.HeadType == objabi.Hwindows {
                ctxt.dope()
        }
        ctxt.addexport()
index 6384c81d5c9eacbbd04c17a162d164f49c8cfec3..b954c05c814b1eafd8b8226f6705e7fdfc8bb118 100644 (file)
@@ -176,7 +176,7 @@ func emitPcln(ctxt *Link, s *sym.Symbol) bool {
        if s == nil {
                return true
        }
-       if ctxt.BuildMode == BuildModePlugin && Headtype == objabi.Hdarwin && onlycsymbol(s) {
+       if ctxt.BuildMode == BuildModePlugin && ctxt.HeadType == objabi.Hdarwin && onlycsymbol(s) {
                return false
        }
        // We want to generate func table entries only for the "lowest level" symbols,
index 1c75ead6c1167db6f160b531c014f23457b34dde..6f019de8cc072cc9c272e8a123056c938bf0b30c 100644 (file)
@@ -62,9 +62,9 @@ func linknew(arch *sys.Arch) *Link {
 
 // computeTLSOffset records the thread-local storage offset.
 func (ctxt *Link) computeTLSOffset() {
-       switch Headtype {
+       switch ctxt.HeadType {
        default:
-               log.Fatalf("unknown thread-local storage offset for %v", Headtype)
+               log.Fatalf("unknown thread-local storage offset for %v", ctxt.HeadType)
 
        case objabi.Hplan9, objabi.Hwindows:
                break
index 572b63a523b1fdb5a8e662f1a24268fb3139d22e..20ac6b7139c08dbc8d7eccbd5ccda4a2742d45c9 100644 (file)
@@ -231,7 +231,7 @@ func putplan9sym(ctxt *Link, x *sym.Symbol, s string, typ SymbolType, addr int64
 
        case AutoSym, ParamSym, FrameSym:
                l := 4
-               if Headtype == objabi.Hplan9 && ctxt.Arch.Family == sys.AMD64 && !Flag8 {
+               if ctxt.HeadType == objabi.Hplan9 && ctxt.Arch.Family == sys.AMD64 && !Flag8 {
                        ctxt.Out.Write32b(uint32(addr >> 32))
                        l = 8
                }
index 4c1be5250ad28fe9ea9bb4fac79cf8ec5eec3845..306d53f571579c985c5baefc3670e2e14513ddef 100644 (file)
@@ -240,7 +240,7 @@ func asmb(ctxt *ld.Link) {
        }
 
        ctxt.Out.SeekSet(0)
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
                ld.Errorf(nil, "unsupported operating system")
        case objabi.Hlinux:
index 3a3aadf720bef19bce1561aaca67c898d871c30d..c5d3451c39b2d1ac21f35e5a595f9a9c011300eb 100644 (file)
@@ -73,9 +73,9 @@ func Init() (*sys.Arch, ld.Arch) {
 }
 
 func archinit(ctxt *ld.Link) {
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
-               ld.Exitf("unknown -H option: %v", ld.Headtype)
+               ld.Exitf("unknown -H option: %v", ctxt.HeadType)
        case objabi.Hlinux: /* mips elf */
                ld.Elfinit(ctxt)
                ld.HEADR = ld.ELFRESERVE
index 98ddcad5a3dff1c6cc2faaef31f0a66057888f31..295a0aafaed71b48ac5b35ae685819ca7b535369 100644 (file)
@@ -226,7 +226,7 @@ func asmb(ctxt *ld.Link) {
                if ctxt.Debugvlog != 0 {
                        ctxt.Logf("%5.2f sym\n", ld.Cputime())
                }
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
@@ -238,7 +238,7 @@ func asmb(ctxt *ld.Link) {
                }
 
                ctxt.Out.SeekSet(int64(symo))
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                if ctxt.Debugvlog != 0 {
@@ -270,7 +270,7 @@ func asmb(ctxt *ld.Link) {
                ctxt.Logf("%5.2f header\n", ld.Cputime())
        }
        ctxt.Out.SeekSet(0)
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
        case objabi.Hplan9: /* plan 9 */
                magic := uint32(4*18*18 + 7)
index c3b810afc4c33d28538ceaface9cb4ceb58d7415..83974e5b5652c0d035d832b3444d93b14fed3638 100644 (file)
@@ -71,9 +71,9 @@ func Init() (*sys.Arch, ld.Arch) {
 }
 
 func archinit(ctxt *ld.Link) {
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
-               ld.Exitf("unknown -H option: %v", ld.Headtype)
+               ld.Exitf("unknown -H option: %v", ctxt.HeadType)
 
        case objabi.Hplan9: /* plan 9 */
                ld.HEADR = 32
index ff011c170c9744e791afd2548879dc99b57ec3a3..4e277f9aa9898658be8556ec74f5cd1708b0d95a 100644 (file)
@@ -958,7 +958,7 @@ func asmb(ctxt *ld.Link) {
                if ctxt.Debugvlog != 0 {
                        ctxt.Logf("%5.2f sym\n", ld.Cputime())
                }
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
@@ -970,7 +970,7 @@ func asmb(ctxt *ld.Link) {
                }
 
                ctxt.Out.SeekSet(int64(symo))
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                if ctxt.Debugvlog != 0 {
@@ -1002,7 +1002,7 @@ func asmb(ctxt *ld.Link) {
                ctxt.Logf("%5.2f header\n", ld.Cputime())
        }
        ctxt.Out.SeekSet(0)
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
        case objabi.Hplan9: /* plan 9 */
                ctxt.Out.Write32(0x647)                      /* magic */
index 49c3fe129d843d619f0fb460e9ba107c153af069..273d9b42cb9da49c451b22b259f4d572103cb2cf 100644 (file)
@@ -75,9 +75,9 @@ func Init() (*sys.Arch, ld.Arch) {
 }
 
 func archinit(ctxt *ld.Link) {
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
-               ld.Exitf("unknown -H option: %v", ld.Headtype)
+               ld.Exitf("unknown -H option: %v", ctxt.HeadType)
 
        case objabi.Hplan9: /* plan 9 */
                ld.HEADR = 32
index d6dc91cd04ea8ec638f72b732c117d82d32cc7be..634ba98dd3b44e04ce62ebbc0138e67cee0bf25b 100644 (file)
@@ -579,7 +579,7 @@ func asmb(ctxt *ld.Link) {
                ctxt.Logf("%5.2f header\n", ld.Cputime())
        }
        ctxt.Out.SeekSet(0)
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
                ld.Errorf(nil, "unsupported operating system")
        case objabi.Hlinux:
index 47b22c1033c4fa170be7af25ff6734e10a472ab8..9ac7eb82174aaaf7bbdec9dfc2acc31b963377e8 100644 (file)
@@ -71,9 +71,9 @@ func Init() (*sys.Arch, ld.Arch) {
 }
 
 func archinit(ctxt *ld.Link) {
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
-               ld.Exitf("unknown -H option: %v", ld.Headtype)
+               ld.Exitf("unknown -H option: %v", ctxt.HeadType)
 
        case objabi.Hlinux: // s390x ELF
                ld.Elfinit(ctxt)
index 208e26aad124fe8d4cce0464abb69e5884bf9346..2230384303ee7c25e4b35979fc081d7e72a19de6 100644 (file)
@@ -316,7 +316,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
                        return true
                }
 
-               if ld.Headtype == objabi.Hdarwin && s.Size == int64(ctxt.Arch.PtrSize) && r.Off == 0 {
+               if ctxt.HeadType == objabi.Hdarwin && s.Size == int64(ctxt.Arch.PtrSize) && r.Off == 0 {
                        // Mach-O relocations are a royal pain to lay out.
                        // They use a compact stateful bytecode representation
                        // that is too much bother to deal with.
@@ -574,7 +574,7 @@ func addpltsym(ctxt *ld.Link, s *sym.Symbol) {
                rel.AddUint32(ctxt.Arch, ld.ELF32_R_INFO(uint32(s.Dynid), uint32(elf.R_386_JMP_SLOT)))
 
                s.Plt = int32(plt.Size - 16)
-       } else if ld.Headtype == objabi.Hdarwin {
+       } else if ctxt.HeadType == objabi.Hdarwin {
                // Same laziness as in 6l.
 
                plt := ctxt.Syms.Lookup(".plt", 0)
@@ -608,7 +608,7 @@ func addgotsym(ctxt *ld.Link, s *sym.Symbol) {
                rel := ctxt.Syms.Lookup(".rel", 0)
                rel.AddAddrPlus(ctxt.Arch, got, int64(s.Got))
                rel.AddUint32(ctxt.Arch, ld.ELF32_R_INFO(uint32(s.Dynid), uint32(elf.R_386_GLOB_DAT)))
-       } else if ld.Headtype == objabi.Hdarwin {
+       } else if ctxt.HeadType == objabi.Hdarwin {
                ctxt.Syms.Lookup(".linkedit.got", 0).AddUint32(ctxt.Arch, uint32(s.Dynid))
        } else {
                ld.Errorf(s, "addgotsym: unsupported binary format")
@@ -660,7 +660,7 @@ func asmb(ctxt *ld.Link) {
        ld.Dwarfblk(ctxt, int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
 
        machlink := uint32(0)
-       if ld.Headtype == objabi.Hdarwin {
+       if ctxt.HeadType == objabi.Hdarwin {
                machlink = uint32(ld.Domacholink(ctxt))
        }
 
@@ -673,7 +673,7 @@ func asmb(ctxt *ld.Link) {
                if ctxt.Debugvlog != 0 {
                        ctxt.Logf("%5.2f sym\n", ld.Cputime())
                }
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
@@ -692,7 +692,7 @@ func asmb(ctxt *ld.Link) {
                }
 
                ctxt.Out.SeekSet(int64(symo))
-               switch ld.Headtype {
+               switch ctxt.HeadType {
                default:
                        if ctxt.IsELF {
                                if ctxt.Debugvlog != 0 {
@@ -734,7 +734,7 @@ func asmb(ctxt *ld.Link) {
                ctxt.Logf("%5.2f headr\n", ld.Cputime())
        }
        ctxt.Out.SeekSet(0)
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
        case objabi.Hplan9: /* plan9 */
                magic := int32(4*11*11 + 7)
index 542ce152047374f54156e46097cb21f952919cf7..6a744dc04e1c1715a9a29c6e0d313eea3cbe28ea 100644 (file)
@@ -69,9 +69,9 @@ func Init() (*sys.Arch, ld.Arch) {
 }
 
 func archinit(ctxt *ld.Link) {
-       switch ld.Headtype {
+       switch ctxt.HeadType {
        default:
-               ld.Exitf("unknown -H option: %v", ld.Headtype)
+               ld.Exitf("unknown -H option: %v", ctxt.HeadType)
 
        case objabi.Hplan9: /* plan 9 */
                ld.HEADR = 32