]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link/internal/ld: make Thearch unexported
authorquasilyte <quasilyte@gmail.com>
Sat, 31 Mar 2018 21:58:48 +0000 (00:58 +0300)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 2 Apr 2018 23:39:16 +0000 (23:39 +0000)
s/Thearch/thearch/

This reduces the amount of exported global variables,
which in turn could make it easier to refactor them later.

Also updated somewhat vague comment about ld.Thearch.
There is no need for Thearch to be exported as Archinit is
called by ld.Main.

Updates #22095

Change-Id: I266b291f6eac0165f70c51964738206e066cea08
Reviewed-on: https://go-review.googlesource.com/103878
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/elf.go
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/macho.go
src/cmd/link/internal/ld/main.go
src/cmd/link/internal/ld/pe.go
src/cmd/link/main.go

index ad801a240bb5ace4dd9a08d32bfc34b95821851b..51ed4b7ab7d2873b524ed9c1f53506612e6de795 100644 (file)
@@ -61,9 +61,9 @@ func isRuntimeDepPkg(pkg string) bool {
 // is used to determine when the section can be split if it becomes too large, to ensure that
 // the trampolines are in the same section as the function that uses them.
 func maxSizeTrampolinesPPC64(s *sym.Symbol, isTramp bool) uint64 {
-       // If Thearch.Trampoline is nil, then trampoline support is not available on this arch.
+       // If thearch.Trampoline is nil, then trampoline support is not available on this arch.
        // A trampoline does not need any dependent trampolines.
-       if Thearch.Trampoline == nil || isTramp {
+       if thearch.Trampoline == nil || isTramp {
                return 0
        }
 
@@ -83,7 +83,7 @@ func maxSizeTrampolinesPPC64(s *sym.Symbol, isTramp bool) uint64 {
 // On PPC64 & PPC64LE the text sections might be split but will still insert trampolines
 // where necessary.
 func trampoline(ctxt *Link, s *sym.Symbol) {
-       if Thearch.Trampoline == nil {
+       if thearch.Trampoline == nil {
                return // no need or no support of trampolines on this arch
        }
 
@@ -103,7 +103,7 @@ func trampoline(ctxt *Link, s *sym.Symbol) {
                        continue
                }
 
-               Thearch.Trampoline(ctxt, r, s)
+               thearch.Trampoline(ctxt, r, s)
        }
 
 }
@@ -195,7 +195,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                        case 8:
                                o = int64(ctxt.Arch.ByteOrder.Uint64(s.P[off:]))
                        }
-                       if !Thearch.Archreloc(ctxt, r, s, &o) {
+                       if !thearch.Archreloc(ctxt, r, s, &o) {
                                Errorf(s, "unknown reloc to %v: %d (%s)", r.Sym.Name, r.Type, sym.RelocName(ctxt.Arch, r.Type))
                        }
                case objabi.R_TLS_LE:
@@ -250,10 +250,10 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                        if ctxt.BuildMode == BuildModePIE && ctxt.IsELF {
                                // We are linking the final executable, so we
                                // can optimize any TLS IE relocation to LE.
-                               if Thearch.TLSIEtoLE == nil {
+                               if thearch.TLSIEtoLE == nil {
                                        log.Fatalf("internal linking of TLS IE not supported on %v", ctxt.Arch.Family)
                                }
-                               Thearch.TLSIEtoLE(s, int(off), int(r.Siz))
+                               thearch.TLSIEtoLE(s, int(off), int(r.Siz))
                                o = int64(ctxt.Tlsoffset)
                                // TODO: o += r.Add when ctxt.Arch.Family != sys.AMD64?
                                // Why do we treat r.Add differently on AMD64?
@@ -445,7 +445,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                }
 
                if r.Variant != sym.RV_NONE {
-                       o = Thearch.Archrelocvariant(ctxt, r, s, o)
+                       o = thearch.Archrelocvariant(ctxt, r, s, o)
                }
 
                if false {
@@ -561,14 +561,14 @@ func dynrelocsym(ctxt *Link, s *sym.Symbol) {
                        // It's expected that some relocations will be done
                        // later by relocsym (R_TLS_LE, R_ADDROFF), so
                        // don't worry if Adddynrel returns false.
-                       Thearch.Adddynrel(ctxt, s, r)
+                       thearch.Adddynrel(ctxt, s, r)
                        continue
                }
                if r.Sym != nil && r.Sym.Type == sym.SDYNIMPORT || r.Type >= 256 {
                        if r.Sym != nil && !r.Sym.Attr.Reachable() {
                                Errorf(s, "dynamic relocation to unreachable symbol %s", r.Sym.Name)
                        }
-                       if !Thearch.Adddynrel(ctxt, s, r) {
+                       if !thearch.Adddynrel(ctxt, s, r) {
                                Errorf(s, "unsupported dynamic relocation for symbol %s (type=%d (%s) stype=%d (%s))", r.Sym.Name, r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Sym.Type, r.Sym.Type)
                        }
                }
@@ -911,7 +911,7 @@ func dosymtype(ctxt *Link) {
 
 // symalign returns the required alignment for the given symbol s.
 func symalign(s *sym.Symbol) int32 {
-       min := int32(Thearch.Minalign)
+       min := int32(thearch.Minalign)
        if s.Align >= min {
                return s.Align
        } else if s.Align != 0 {
@@ -922,7 +922,7 @@ func symalign(s *sym.Symbol) int32 {
                // If we align it, we waste a lot of space to padding.
                return min
        }
-       align := int32(Thearch.Maxalign)
+       align := int32(thearch.Maxalign)
        for int64(align) > s.Size && align > min {
                align >>= 1
        }
index 3a739fb3d56758640db74c8b164427bbded5772e..cd71ed35152ab3fc0cfcdfd6dae33d4544621887 100644 (file)
@@ -1372,24 +1372,24 @@ func writeframes(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
        fs.AddUint8(0)                                             // augmentation ""
        dwarf.Uleb128put(dwarfctxt, fs, 1)                         // code_alignment_factor
        dwarf.Sleb128put(dwarfctxt, fs, dataAlignmentFactor)       // all CFI offset calculations include multiplication with this factor
-       dwarf.Uleb128put(dwarfctxt, fs, int64(Thearch.Dwarfreglr)) // return_address_register
+       dwarf.Uleb128put(dwarfctxt, fs, int64(thearch.Dwarfreglr)) // return_address_register
 
        fs.AddUint8(dwarf.DW_CFA_def_cfa)                          // Set the current frame address..
-       dwarf.Uleb128put(dwarfctxt, fs, int64(Thearch.Dwarfregsp)) // ...to use the value in the platform's SP register (defined in l.go)...
+       dwarf.Uleb128put(dwarfctxt, fs, int64(thearch.Dwarfregsp)) // ...to use the value in the platform's SP register (defined in l.go)...
        if haslinkregister(ctxt) {
                dwarf.Uleb128put(dwarfctxt, fs, int64(0)) // ...plus a 0 offset.
 
                fs.AddUint8(dwarf.DW_CFA_same_value) // The platform's link register is unchanged during the prologue.
-               dwarf.Uleb128put(dwarfctxt, fs, int64(Thearch.Dwarfreglr))
+               dwarf.Uleb128put(dwarfctxt, fs, int64(thearch.Dwarfreglr))
 
                fs.AddUint8(dwarf.DW_CFA_val_offset)                       // The previous value...
-               dwarf.Uleb128put(dwarfctxt, fs, int64(Thearch.Dwarfregsp)) // ...of the platform's SP register...
+               dwarf.Uleb128put(dwarfctxt, fs, int64(thearch.Dwarfregsp)) // ...of the platform's SP register...
                dwarf.Uleb128put(dwarfctxt, fs, int64(0))                  // ...is CFA+0.
        } else {
                dwarf.Uleb128put(dwarfctxt, fs, int64(ctxt.Arch.PtrSize)) // ...plus the word size (because the call instruction implicitly adds one word to the frame).
 
                fs.AddUint8(dwarf.DW_CFA_offset_extended)                                      // The previous value...
-               dwarf.Uleb128put(dwarfctxt, fs, int64(Thearch.Dwarfreglr))                     // ...of the return address...
+               dwarf.Uleb128put(dwarfctxt, fs, int64(thearch.Dwarfreglr))                     // ...of the return address...
                dwarf.Uleb128put(dwarfctxt, fs, int64(-ctxt.Arch.PtrSize)/dataAlignmentFactor) // ...is saved at [CFA - (PtrSize/4)].
        }
 
@@ -1432,13 +1432,13 @@ func writeframes(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
                                        // The return address is preserved at (CFA-frame_size)
                                        // after a stack frame has been allocated.
                                        deltaBuf = append(deltaBuf, dwarf.DW_CFA_offset_extended_sf)
-                                       deltaBuf = dwarf.AppendUleb128(deltaBuf, uint64(Thearch.Dwarfreglr))
+                                       deltaBuf = dwarf.AppendUleb128(deltaBuf, uint64(thearch.Dwarfreglr))
                                        deltaBuf = dwarf.AppendSleb128(deltaBuf, -int64(pcsp.value)/dataAlignmentFactor)
                                } else {
                                        // The return address is restored into the link register
                                        // when a stack frame has been de-allocated.
                                        deltaBuf = append(deltaBuf, dwarf.DW_CFA_same_value)
-                                       deltaBuf = dwarf.AppendUleb128(deltaBuf, uint64(Thearch.Dwarfreglr))
+                                       deltaBuf = dwarf.AppendUleb128(deltaBuf, uint64(thearch.Dwarfreglr))
                                }
                                deltaBuf = appendPCDeltaCFA(ctxt.Arch, deltaBuf, int64(nextpc)-int64(pcsp.pc), int64(pcsp.value))
                        } else {
index d56a2359d3876d2f66770904dd1d9bc45c4992d0..817ba4693b539f6c1b0f0148e1e0dd2242dd48e7 100644 (file)
@@ -1366,7 +1366,7 @@ func elfrelocsect(ctxt *Link, sect *sym.Section, syms []*sym.Symbol) {
                        if !r.Xsym.Attr.Reachable() {
                                Errorf(s, "unreachable reloc %d (%s) target %v", r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Xsym.Name)
                        }
-                       if !Thearch.Elfreloc1(ctxt, r, int64(uint64(s.Value+int64(r.Off))-sect.Vaddr)) {
+                       if !thearch.Elfreloc1(ctxt, r, int64(uint64(s.Value+int64(r.Off))-sect.Vaddr)) {
                                Errorf(s, "unsupported obj reloc %d (%s)/%d to %s", r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Siz, r.Sym.Name)
                        }
                }
@@ -1599,7 +1599,7 @@ func (ctxt *Link) doelf() {
                        s.Type = sym.SELFRXSECT
                }
 
-               Thearch.Elfsetupplt(ctxt)
+               thearch.Elfsetupplt(ctxt)
 
                s = ctxt.Syms.Lookup(elfRelType+".plt", 0)
                s.Attr |= sym.AttrReachable
@@ -1845,22 +1845,22 @@ func Asmbelf(ctxt *Link, symo int64) {
                if interpreter == "" {
                        switch ctxt.HeadType {
                        case objabi.Hlinux:
-                               interpreter = Thearch.Linuxdynld
+                               interpreter = thearch.Linuxdynld
 
                        case objabi.Hfreebsd:
-                               interpreter = Thearch.Freebsddynld
+                               interpreter = thearch.Freebsddynld
 
                        case objabi.Hnetbsd:
-                               interpreter = Thearch.Netbsddynld
+                               interpreter = thearch.Netbsddynld
 
                        case objabi.Hopenbsd:
-                               interpreter = Thearch.Openbsddynld
+                               interpreter = thearch.Openbsddynld
 
                        case objabi.Hdragonfly:
-                               interpreter = Thearch.Dragonflydynld
+                               interpreter = thearch.Dragonflydynld
 
                        case objabi.Hsolaris:
-                               interpreter = Thearch.Solarisdynld
+                               interpreter = thearch.Solarisdynld
                        }
                }
 
index d3f5e7e640fa93b78fd5e18cd87be939fa25b38c..7d930746148fdc66acb7b6ec26618fc182b7eb57 100644 (file)
@@ -124,7 +124,7 @@ type Arch struct {
 }
 
 var (
-       Thearch Arch
+       thearch Arch
        Lcsize  int32
        rpath   Rpath
        Spsize  int32
@@ -212,7 +212,7 @@ func mayberemoveoutfile() {
 }
 
 func libinit(ctxt *Link) {
-       Funcalign = Thearch.Funcalign
+       Funcalign = thearch.Funcalign
 
        // add goroot to the end of the libdir list.
        suffix := ""
index 2b38ec00008bc11fdceaf41a5483d62c490a5287..12037069c8027f78d217e5d2b4b89fc40eb97d8c 100644 (file)
@@ -927,7 +927,7 @@ func machorelocsect(ctxt *Link, sect *sym.Section, syms []*sym.Symbol) {
                        if !r.Xsym.Attr.Reachable() {
                                Errorf(s, "unreachable reloc %d (%s) target %v", r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Xsym.Name)
                        }
-                       if !Thearch.Machoreloc1(ctxt.Arch, ctxt.Out, s, r, int64(uint64(s.Value+int64(r.Off))-sect.Vaddr)) {
+                       if !thearch.Machoreloc1(ctxt.Arch, ctxt.Out, s, r, int64(uint64(s.Value+int64(r.Off))-sect.Vaddr)) {
                                Errorf(s, "unsupported obj reloc %d (%s)/%d to %s", r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Siz, r.Sym.Name)
                        }
                }
index f86abbc6a65b930fb2dc18375e112227efc4d29d..8a812c924ae2084bcc6f153047c254ffa2f23550 100644 (file)
@@ -97,7 +97,7 @@ var (
 
 // Main is the main entry point for the linker code.
 func Main(arch *sys.Arch, theArch Arch) {
-       Thearch = theArch
+       thearch = theArch
        ctxt := linknew(arch)
        ctxt.Bso = bufio.NewWriter(os.Stdout)
 
@@ -168,7 +168,7 @@ func Main(arch *sys.Arch, theArch Arch) {
        }
 
        ctxt.computeTLSOffset()
-       Thearch.Archinit(ctxt)
+       thearch.Archinit(ctxt)
 
        if ctxt.linkShared && !ctxt.IsELF {
                Exitf("-linkshared can only be used on elf systems")
@@ -214,7 +214,7 @@ func Main(arch *sys.Arch, theArch Arch) {
                ctxt.dope()
        }
        ctxt.addexport()
-       Thearch.Gentext(ctxt) // trampolines, call stubs, etc.
+       thearch.Gentext(ctxt) // trampolines, call stubs, etc.
        ctxt.textbuildid()
        ctxt.textaddress()
        ctxt.pclntab()
@@ -224,7 +224,7 @@ func Main(arch *sys.Arch, theArch Arch) {
        ctxt.dodata()
        ctxt.address()
        ctxt.reloc()
-       Thearch.Asmb(ctxt)
+       thearch.Asmb(ctxt)
        ctxt.undef()
        ctxt.hostlink()
        ctxt.archive()
index 8586c359adbb266f23e81f2370d7a1b13326728e..d07f201557ec17761dea8dd8cf39d01739b72a1c 100644 (file)
@@ -538,7 +538,7 @@ func (f *peFile) emitRelocations(ctxt *Link) {
                                if r.Xsym.Dynid < 0 {
                                        Errorf(sym, "reloc %d to non-coff symbol %s (outer=%s) %d", r.Type, r.Sym.Name, r.Xsym.Name, r.Sym.Type)
                                }
-                               if !Thearch.PEreloc1(ctxt.Arch, ctxt.Out, sym, r, int64(uint64(sym.Value+int64(r.Off))-base)) {
+                               if !thearch.PEreloc1(ctxt.Arch, ctxt.Out, sym, r, int64(uint64(sym.Value+int64(r.Off))-base)) {
                                        Errorf(sym, "unsupported obj reloc %d/%d to %s", r.Type, r.Siz, r.Sym.Name)
                                }
                                relocs++
index 6bc9b5dcb60f4344294694a78b3268fe13386070..b1a66f545405a4f47bd5fc20788222145ff2678c 100644 (file)
@@ -32,7 +32,7 @@ import (
 // Then control flow passes to ld.Main, which parses flags, makes
 // some configuration decisions, and then gives the architecture
 // packages a second chance to modify the linker's configuration
-// via the ld.Thearch.Archinit function.
+// via the ld.Arch.Archinit function.
 
 func main() {
        var arch *sys.Arch