From: Paul E. Murphy Date: Mon, 19 Sep 2022 21:48:49 +0000 (-0500) Subject: cmd/link: refactor usage of SymLocalentry helper functions X-Git-Tag: go1.20rc1~902 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=edd1273b841050e96d9ddd937fc00c0eebe10f1b;p=gostls13.git cmd/link: refactor usage of SymLocalentry helper functions PPC64 ELFv2 uses the st_other field of a symbol to specify an offset from the global entry point to its local entry point. Similarly, some values (i.e 1) may also require additional linker support which is missing today. For now, generate an error if we encounter unsupported local entry values on PPC64, and update the Localentry values to use bytes, not 32b instruction words. Similarly, ELFv2 1.5 also updates the wording of values 2-6. They now map to a specific number of bytes. Change-Id: Id1b71c3b0fea982bdcfb7eac91d9f93e04ae43f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/431876 TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui Run-TryBot: Paul Murphy Reviewed-by: Dmitri Shuralyov --- diff --git a/src/cmd/link/internal/loadelf/ldelf.go b/src/cmd/link/internal/loadelf/ldelf.go index 74f7cb15a0..da02223212 100644 --- a/src/cmd/link/internal/loadelf/ldelf.go +++ b/src/cmd/link/internal/loadelf/ldelf.go @@ -634,10 +634,16 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader, if elf.Machine(elfobj.machine) == elf.EM_PPC64 { flag := int(elfsym.other) >> 5 - if 2 <= flag && flag <= 6 { - l.SetSymLocalentry(s, 1<= Sym(len(l.objSyms)) || i == 0 { diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go index 21bc430e04..70d2cf3f0b 100644 --- a/src/cmd/link/internal/ppc64/asm.go +++ b/src/cmd/link/internal/ppc64/asm.go @@ -380,7 +380,7 @@ func addelfdynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s lo // 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.) - su.SetRelocAdd(rIdx, r.Add()+int64(ldr.SymLocalentry(targ))*4) + su.SetRelocAdd(rIdx, r.Add()+int64(ldr.SymLocalentry(targ))) if targType == sym.SDYNIMPORT { // Should have been handled in elfsetupplt