Commit 2975914a authored by Than McIntosh's avatar Than McIntosh

cmd/link: move Localentry field in sym.Symbol to cold section

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