Commit 8c3cc58d authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle Committed by Ian Lance Taylor

cmd/internal/ld: remove some dead code

Just little bits and pieces I noticed were unused in passing, and
some more found with https://github.com/opennota/check.

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