From 1a8b3f5aa270e8f2ebcc100f05843bc8a7c589c0 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: May 06 2021 14:47:45 +0000 Subject: import golang-1.16.1-3.module+el8.5.0+10861+aabff380 --- diff --git a/SOURCES/rhbz1956891.patch b/SOURCES/rhbz1956891.patch new file mode 100644 index 0000000..0d201a3 --- /dev/null +++ b/SOURCES/rhbz1956891.patch @@ -0,0 +1,69 @@ +From 9ed736ac2a99aa2e7ef7d8bed3b01ca8b20a6f80 Mon Sep 17 00:00:00 2001 +From: Lynn Boger +Date: Thu, 29 Apr 2021 16:07:25 -0500 +Subject: [PATCH] cmd/link/internal: fix use of DynlinkingGo with ppc64le trampolines + +When creating programs with large text sections on ppc64le, +trampolines are needed for calls that are too far; however +they are not created if the code is generated such that the TOC +register r2 is initialized and maintained in the code because +then the external linker can create the trampolines. Previously +the function DynlinkingGo was used to determine this but in the +case where plugins are used, this could return true even though +r2 is not valid. + +To fix this problem I've added a new function r2Valid which returns +true when the build options indicate that the r2 is +initialized and maintained. Because of the ways that +DynlinkingGo is used I wanted to maintain its previous +behavior. + +Fixes #45850 + +Change-Id: I6d902eba6ad41757aa6474948b79acdbd479cb38 +Reviewed-on: https://go-review.googlesource.com/c/go/+/315289 +Trust: Lynn Boger +Run-TryBot: Lynn Boger +Reviewed-by: Cherry Zhang +TryBot-Result: Go Bot +--- + +diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go +index 0638502..b877864 100644 +--- a/src/cmd/link/internal/ppc64/asm.go ++++ b/src/cmd/link/internal/ppc64/asm.go +@@ -651,6 +651,16 @@ + return int64(o2)<<32 | int64(o1) + } + ++// Determine if the code was compiled so that the TOC register R2 is initialized and maintained ++func r2Valid(ctxt *ld.Link) bool { ++ switch ctxt.BuildMode { ++ case ld.BuildModeCArchive, ld.BuildModeCShared, ld.BuildModePIE, ld.BuildModeShared, ld.BuildModePlugin: ++ return true ++ } ++ // -linkshared option ++ return ctxt.IsSharedGoLink() ++} ++ + // resolve direct jump relocation r in s, and add trampoline if necessary + func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) { + +@@ -658,7 +668,7 @@ + // For internal linking, trampolines are always created for long calls. + // For external linking, the linker can insert a call stub to handle a long call, but depends on having the TOC address in + // r2. For those build modes with external linking where the TOC address is not maintained in r2, trampolines must be created. +- if ctxt.IsExternal() && (ctxt.DynlinkingGo() || ctxt.BuildMode == ld.BuildModeCArchive || ctxt.BuildMode == ld.BuildModeCShared || ctxt.BuildMode == ld.BuildModePIE) { ++ if ctxt.IsExternal() && r2Valid(ctxt) { + // No trampolines needed since r2 contains the TOC + return + } +@@ -712,7 +722,7 @@ + } + } + if ldr.SymType(tramp) == 0 { +- if ctxt.DynlinkingGo() || ctxt.BuildMode == ld.BuildModeCArchive || ctxt.BuildMode == ld.BuildModeCShared || ctxt.BuildMode == ld.BuildModePIE { ++ if r2Valid(ctxt) { + // Should have returned for above cases + ctxt.Errorf(s, "unexpected trampoline for shared or dynamic linking") + } else { diff --git a/SPECS/golang.spec b/SPECS/golang.spec index c806a0d..e940525 100644 --- a/SPECS/golang.spec +++ b/SPECS/golang.spec @@ -101,7 +101,7 @@ Name: golang Version: %{go_version} -Release: 2%{?dist} +Release: 3%{?dist} Summary: The Go Programming Language # source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain License: BSD and Public Domain @@ -155,6 +155,10 @@ Patch1939923: skip_test_rhbz1939923.patch # https://go-review.googlesource.com/c/go/+/314449/ Patch1955032: rhbz1955032.patch +# cmd/link/internal: fix use of DynlinkingGo with ppc64le trampolines +# https://go-review.googlesource.com/c/go/+/315289 +Patch1956891: rhbz1956891.patch + # Having documentation separate was broken Obsoletes: %{name}-docs < 1.1-4 @@ -254,6 +258,8 @@ Requires: %{name} = %{version}-%{release} %patch1955032 -p1 +%patch1956891 -p1 + cp %{SOURCE1} ./src/runtime/ %build @@ -520,6 +526,9 @@ cd .. %endif %changelog +* Tue May 04 2021 Alejandro Sáez - 1.16.1-3 +- Resolves: rhbz#1956891 + * Thu Apr 29 2021 Alejandro Sáez - 1.16.1-2 - Resolves: rhbz#1955032