]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: move Localentry field in sym.Symbol to cold section
authorThan McIntosh <thanm@google.com>
Tue, 17 Jul 2018 18:38:34 +0000 (14:38 -0400)
committerThan McIntosh <thanm@google.com>
Thu, 30 Aug 2018 12:35:03 +0000 (12:35 +0000)
The sym.Symbol 'Localentry' field is used only with cgo and/or
external linking on MachoPPC. Relocate it to sym.AuxSymbol since it is
infrequently used, so as to shrink the main Symbol struct.

Updates #26186

Change-Id: I5872aa3f059270c2a091016d235a1a732695e411
Reviewed-on: https://go-review.googlesource.com/125477
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/link/internal/loadelf/ldelf.go
src/cmd/link/internal/ppc64/asm.go
src/cmd/link/internal/sym/sizeof_test.go
src/cmd/link/internal/sym/symbol.go

index 8e32e7dee61906119f51c74e9b3bcc265a96ee77..d85d91948a750aa3ae12a0631397d9656fe36617 100644 (file)
@@ -820,7 +820,7 @@ func Load(arch *sys.Arch, syms *sym.Symbols, f *bio.Reader, pkg string, length i
                if elfobj.machine == ElfMachPower64 {
                        flag := int(elfsym.other) >> 5
                        if 2 <= flag && flag <= 6 {
-                               s.Localentry = 1 << uint(flag-2)
+                               s.SetLocalentry(1 << uint(flag-2))
                        } else if flag == 7 {
                                return errorf("%v: invalid sym.other 0x%x", s, elfsym.other)
                        }
index 825366c567a7a1b4eebefaf437bd3f7b246b4199..2baa9c1de191be019d265dfc87d6869c2a1cf99d 100644 (file)
@@ -280,7 +280,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
                // callee. Hence, we need to go to the local entry
                // point.  (If we don't do this, the callee will try
                // to use r12 to compute r2.)
-               r.Add += int64(r.Sym.Localentry) * 4
+               r.Add += int64(r.Sym.Localentry()) * 4
 
                if targ.Type == sym.SDYNIMPORT {
                        // Should have been handled in elfsetupplt
index 5d501bda499c2399ce2eab4f0c17f42e3e3eeb3e..814ec4237397474ba21e573bcdc6b7590ecf3ac2 100644 (file)
@@ -23,7 +23,7 @@ func TestSizeof(t *testing.T) {
                _32bit uintptr     // size on 32bit platforms
                _64bit uintptr     // size on 64bit platforms
        }{
-               {Symbol{}, 124, 200},
+               {Symbol{}, 120, 192},
        }
 
        for _, tt := range tests {
index 245d62003baa1d289484f1f7237e88e057c0155c..7739737591a163269a803c68a2e779100ea100ad 100644 (file)
@@ -18,7 +18,6 @@ type Symbol struct {
        Type        SymKind
        Version     int16
        Attr        Attribute
-       Localentry  uint8
        Dynid       int32
        Plt         int32
        Got         int32
@@ -49,6 +48,7 @@ type AuxSymbol struct {
        extname    string
        dynimplib  string
        dynimpvers string
+       localentry uint8
 }
 
 func (s *Symbol) String() string {
@@ -327,6 +327,23 @@ func (s *Symbol) ResetDyninfo() {
        }
 }
 
+func (s *Symbol) Localentry() uint8 {
+       if s.auxinfo == nil {
+               return 0
+       }
+       return s.auxinfo.localentry
+}
+
+func (s *Symbol) SetLocalentry(val uint8) {
+       if s.auxinfo == nil {
+               if val != 0 {
+                       return
+               }
+               s.makeAuxInfo()
+       }
+       s.auxinfo.localentry = val
+}
+
 // SortSub sorts a linked-list (by Sub) of *Symbol by Value.
 // Used for sub-symbols when loading host objects (see e.g. ldelf.go).
 func SortSub(l *Symbol) *Symbol {