]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/objabi: shrink SymType down to a uint8
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Thu, 27 Apr 2017 20:07:56 +0000 (08:07 +1200)
committerMichael Hudson-Doyle <michael.hudson@canonical.com>
Fri, 28 Apr 2017 20:02:20 +0000 (20:02 +0000)
Now that it only takes small values.

Change-Id: I08086d392529d8775b470d65afc2475f8d0e7f4a
Reviewed-on: https://go-review.googlesource.com/42030
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/internal/obj/objfile.go
src/cmd/internal/objabi/symkind.go
src/cmd/internal/objabi/symkind_string.go
src/cmd/link/internal/ld/objfile.go

index b81d5693481f77a6fd2b33db0948b35711cebb57..2528064a8263960dfeef325a599a570b296cde6a 100644 (file)
@@ -283,7 +283,7 @@ func (w *objWriter) writeSym(s *LSym) {
        }
 
        w.wr.WriteByte(symPrefix)
-       w.writeInt(int64(s.Type))
+       w.wr.WriteByte(byte(s.Type))
        w.writeRefIndex(s)
        flags := int64(0)
        if s.DuplicateOK() {
index 6219436fb7deb2bfd32c2d514947414e10955c13..62a7efd964084f3f355b5dfa2df9db4e395e0007 100644 (file)
@@ -31,7 +31,7 @@
 package objabi
 
 // A SymKind describes the kind of memory represented by a symbol.
-type SymKind int16
+type SymKind uint8
 
 // Defined SymKind values.
 //
index b28628b520706035819d9d17052ca3d31322b9bc..aabcfd2d54c1aee8caa84c133310402edc8f52cf 100644 (file)
@@ -9,7 +9,7 @@ const _SymKind_name = "SxxxSTEXTSRODATASNOPTRDATASDATASBSSSNOPTRBSSSTLSBSSSDWARF
 var _SymKind_index = [...]uint8{0, 4, 9, 16, 26, 31, 35, 44, 51, 61}
 
 func (i SymKind) String() string {
-       if i < 0 || i >= SymKind(len(_SymKind_index)-1) {
+       if i >= SymKind(len(_SymKind_index)-1) {
                return fmt.Sprintf("SymKind(%d)", i)
        }
        return _SymKind_name[_SymKind_index[i]:_SymKind_index[i+1]]
index 2bfa5d3e7c7d6c034e8d8194c2748cc7127a91e4..c91fe2845844f949de582018bf9d84e36114de7b 100644 (file)
@@ -155,10 +155,15 @@ func (r *objReader) readSlices() {
 const symPrefix = 0xfe
 
 func (r *objReader) readSym() {
-       if c, err := r.rd.ReadByte(); c != symPrefix || err != nil {
+       var c byte
+       var err error
+       if c, err = r.rd.ReadByte(); c != symPrefix || err != nil {
                log.Fatalln("readSym out of sync")
        }
-       t := abiSymKindToSymKind[r.readInt()]
+       if c, err = r.rd.ReadByte(); err != nil {
+               log.Fatalln("error reading input: ", err)
+       }
+       t := abiSymKindToSymKind[c]
        s := r.readSymIndex()
        flags := r.readInt()
        dupok := flags&1 != 0