diff --git a/src/cmd/internal/ld/elf.go b/src/cmd/internal/ld/elf.go index 9e85885067..3fc6907d76 100644 --- a/src/cmd/internal/ld/elf.go +++ b/src/cmd/internal/ld/elf.go @@ -694,12 +694,6 @@ const ( * marshal a 32-bit representation from the 64-bit structure. */ -var numelfphdr int - -var numelfshdr int - -var elfstrsize int - var Elfstrdat []byte /* diff --git a/src/cmd/internal/ld/ld.go b/src/cmd/internal/ld/ld.go index 3397dd288e..a0f1f325bd 100644 --- a/src/cmd/internal/ld/ld.go +++ b/src/cmd/internal/ld/ld.go @@ -104,16 +104,6 @@ func addlibpath(ctxt *Link, srcref string, objref string, file string, pkg strin l.Pkg = pkg } -var fnuxi8 [8]uint8 - -var fnuxi4 [4]uint8 - -var inuxi1 [1]uint8 - -var inuxi2 [2]uint8 - -var inuxi8 [8]uint8 - func atolwhex(s string) int64 { n, _ := strconv.ParseInt(s, 0, 64) return n diff --git a/src/cmd/internal/ld/lib.go b/src/cmd/internal/ld/lib.go index 788f648108..324a8d4d02 100644 --- a/src/cmd/internal/ld/lib.go +++ b/src/cmd/internal/ld/lib.go @@ -104,23 +104,15 @@ type Arch struct { Vput func(uint64) } -var Thearch Arch - -var datap *LSym - -var Debug [128]int - -var literal string - -var Lcsize int32 - -var rpath string - -var Spsize int32 - -var symlist *LSym - -var Symsize int32 +var ( + Thearch Arch + datap *LSym + Debug [128]int + Lcsize int32 + rpath string + Spsize int32 + Symsize int32 +) // Terrible but standard terminology. // A segment describes a block of file to load into memory. @@ -155,65 +147,36 @@ type Section struct { Rellen uint64 } -var Thestring string - -var Thelinkarch *LinkArch - -var outfile string - -var ndynexp int - -var dynexp []*LSym - -var nldflag int - -var ldflag []string - -var havedynamic int - -var Funcalign int - -var iscgo bool - -var elfglobalsymndx int - -var flag_installsuffix string - -var flag_race int - -var Flag_shared int - -var tracksym string - -var interpreter string - -var tmpdir string - -var extld string - -var extldflags string - -var debug_s int // backup old value of debug['s'] - -var Ctxt *Link - -var HEADR int32 - -var HEADTYPE int32 - -var INITRND int32 - -var INITTEXT int64 - -var INITDAT int64 - -var INITENTRY string /* entry point */ - -var nerrors int - -var Linkmode int - -var liveness int64 +var ( + Thestring string + Thelinkarch *LinkArch + outfile string + dynexp []*LSym + ldflag []string + havedynamic int + Funcalign int + iscgo bool + elfglobalsymndx int + flag_installsuffix string + flag_race int + Flag_shared int + tracksym string + interpreter string + tmpdir string + extld string + extldflags string + debug_s int // backup old value of debug['s'] + Ctxt *Link + HEADR int32 + HEADTYPE int32 + INITRND int32 + INITTEXT int64 + INITDAT int64 + INITENTRY string /* entry point */ + nerrors int + Linkmode int + liveness int64 +) // for dynexport field of LSym const ( @@ -221,19 +184,12 @@ const ( CgoExportStatic = 1 << 1 ) -var Segtext Segment - -var Segrodata Segment - -var Segdata Segment - -var Segdwarf Segment - -type Endian struct { - e16 func([]byte) uint16 - e32 func([]byte) uint32 - e64 func([]byte) uint64 -} +var ( + Segtext Segment + Segrodata Segment + Segdata Segment + Segdwarf Segment +) /* set by call to mywhatsys() */ @@ -244,13 +200,12 @@ const ( Pkgdef ) -var headstring string - -// buffered output - -var Bso Biobuf - -var coutbuf Biobuf +var ( + headstring string + // buffered output + Bso Biobuf + coutbuf Biobuf +) const ( // Whether to assume that the external linker is "gold" @@ -263,21 +218,16 @@ const ( pkgname = "__.PKGDEF" ) -var cout *os.File - -var version int - -// Set if we see an object compiled by the host compiler that is not -// from a package that is known to support internal linking mode. -var externalobj = false - -var goroot string - -var goarch string - -var goos string - -var theline string +var ( + cout *os.File + // Set if we see an object compiled by the host compiler that is not + // from a package that is known to support internal linking mode. + externalobj = false + goroot string + goarch string + goos string + theline string +) func Lflag(arg string) { Ctxt.Libdir = append(Ctxt.Libdir, arg) @@ -658,10 +608,6 @@ type Hostobj struct { var hostobj []Hostobj -var nhostobj int - -var mhostobj int - // These packages can use internal linking mode. // Others trigger external mode. var internalpkg = []string{ @@ -1026,11 +972,6 @@ eof: Diag("truncated object file: %s", pn) } -func zerosig(sp string) { - s := Linklookup(Ctxt, sp, 0) - s.Sig = 0 -} - func mywhatsys() { goroot = obj.Getgoroot() goos = obj.Getgoos() @@ -1041,18 +982,6 @@ func mywhatsys() { } } -func pathchar() int { - return '/' -} - -var hunk []byte - -var nhunk uint32 - -const ( - NHUNK = 10 << 20 -) - // Copied from ../gc/subr.c:/^pathtoprefix; must stay in sync. /* * Convert raw string to the prefix that will be used in the symbol table. @@ -1082,19 +1011,6 @@ func pathtoprefix(s string) string { return s } -func iconv(p string) string { - if p == "" { - var fp string - fp += "" - return fp - } - - p = pathtoprefix(p) - var fp string - fp += p - return fp -} - func addsection(seg *Segment, name string, rwx int) *Section { var l **Section @@ -1133,19 +1049,16 @@ func Be64(b []byte) uint64 { return uint64(Be32(b))<<32 | uint64(Be32(b[4:])) } -var be = Endian{Be16, Be32, Be64} - -var le = Endian{Le16, Le32, Le64} - type Chain struct { sym *LSym up *Chain limit int // limit on entry to sym } -var morestack *LSym - -var newstack *LSym +var ( + morestack *LSym + newstack *LSym +) // TODO: Record enough information in new object files to // allow stack checks here. diff --git a/src/cmd/internal/ld/link.go b/src/cmd/internal/ld/link.go index 9047e7098c..923bf52aeb 100644 --- a/src/cmd/internal/ld/link.go +++ b/src/cmd/internal/ld/link.go @@ -50,7 +50,6 @@ type LSym struct { Localentry uint8 Onlist uint8 Dynid int32 - Sig int32 Plt int32 Got int32 Align int32 @@ -128,7 +127,6 @@ type LinkArch struct { ByteOrder binary.ByteOrder Name string Thechar int - Endian int32 Minlc int Ptrsize int Regsize int diff --git a/src/cmd/internal/ld/macho.go b/src/cmd/internal/ld/macho.go index 2cef2debe9..66b5aeb338 100644 --- a/src/cmd/internal/ld/macho.go +++ b/src/cmd/internal/ld/macho.go @@ -95,10 +95,6 @@ var load []MachoLoad var seg [16]MachoSeg -var nload int - -var mload int - var nseg int var ndebug int @@ -187,8 +183,6 @@ func newMachoSect(seg *MachoSeg, name string, segname string) *MachoSect { var dylib []string -var ndylib int - var linkoff int64 func machowrite() int { diff --git a/src/cmd/internal/ld/pobj.go b/src/cmd/internal/ld/pobj.go index a161a456d2..221f2b06a9 100644 --- a/src/cmd/internal/ld/pobj.go +++ b/src/cmd/internal/ld/pobj.go @@ -40,10 +40,6 @@ import ( // Reading object files. -const noname = "" - -var paramspace string = "FP" - func Ldmain() { Ctxt = linknew(Thelinkarch) Ctxt.Thechar = int32(Thearch.Thechar) @@ -189,7 +185,6 @@ func Ldmain() { checkgo() deadcode() callgraph() - paramspace = "SP" /* (FP) now (SP) on output */ doelf() if HEADTYPE == Hdarwin { diff --git a/src/cmd/internal/ld/sym.go b/src/cmd/internal/ld/sym.go index fd02ed0285..054716f668 100644 --- a/src/cmd/internal/ld/sym.go +++ b/src/cmd/internal/ld/sym.go @@ -168,7 +168,6 @@ func linknewsym(ctxt *Link, symb string, v int) *LSym { s.Type = 0 s.Version = int16(v) s.Value = 0 - s.Sig = 0 s.Size = 0 ctxt.Nsymbol++ diff --git a/src/cmd/internal/ld/symtab.go b/src/cmd/internal/ld/symtab.go index d6577ad231..94ae6a55d2 100644 --- a/src/cmd/internal/ld/symtab.go +++ b/src/cmd/internal/ld/symtab.go @@ -34,8 +34,6 @@ import "strings" // Symbol table. -var maxelfstr int - func putelfstr(s string) int { if len(Elfstrdat) == 0 && s != "" { // first entry must be empty string diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go index 5e1733f91a..2151586cfb 100644 --- a/src/cmd/internal/obj/link.go +++ b/src/cmd/internal/obj/link.go @@ -106,7 +106,6 @@ type LSym struct { Printed uint8 Symid int16 Dynid int32 - Sig int32 Plt int32 Got int32 Align int32 diff --git a/src/cmd/internal/obj/sym.go b/src/cmd/internal/obj/sym.go index 7dafb2de04..1557446457 100644 --- a/src/cmd/internal/obj/sym.go +++ b/src/cmd/internal/obj/sym.go @@ -231,7 +231,6 @@ func linknewsym(ctxt *Link, symb string, v int) *LSym { s.Type = 0 s.Version = int16(v) s.Value = 0 - s.Sig = 0 s.Size = 0 ctxt.Nsymbol++