diff --git a/src/cmd/link/internal/loadelf/ldelf.go b/src/cmd/link/internal/loadelf/ldelf.go index 8e32e7dee61906..d85d91948a750a 100644 --- a/src/cmd/link/internal/loadelf/ldelf.go +++ b/src/cmd/link/internal/loadelf/ldelf.go @@ -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) } diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go index 825366c567a7a1..2baa9c1de191be 100644 --- a/src/cmd/link/internal/ppc64/asm.go +++ b/src/cmd/link/internal/ppc64/asm.go @@ -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 diff --git a/src/cmd/link/internal/sym/sizeof_test.go b/src/cmd/link/internal/sym/sizeof_test.go index 5d501bda499c23..814ec423739747 100644 --- a/src/cmd/link/internal/sym/sizeof_test.go +++ b/src/cmd/link/internal/sym/sizeof_test.go @@ -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 { diff --git a/src/cmd/link/internal/sym/symbol.go b/src/cmd/link/internal/sym/symbol.go index 245d62003baa1d..7739737591a163 100644 --- a/src/cmd/link/internal/sym/symbol.go +++ b/src/cmd/link/internal/sym/symbol.go @@ -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 {