backport patch to fix bug of golang plugin mode

Signed-off-by: hubin <hubin73@huawei.com>
This commit is contained in:
hubin 2022-06-28 19:16:14 +08:00 committed by hanchao
parent 9ab15eb485
commit e40a694498
2 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,39 @@
From c872b0594f716a2a0799b07d7226a45f02c005f1 Mon Sep 17 00:00:00 2001
From: Cherry Mui <cherryyz@google.com>
Date: Wed, 16 Mar 2022 13:07:57 -0400
Subject: [PATCH] cmd/link: mark unexported methods for plugins
When plugin is used, we already mark all exported methods
reachable. However, when the plugin and the host program share
a common package, an unexported method could also be reachable
from both the plugin and the host via interfaces. We need to mark
them as well.
Fixes #51621.
Change-Id: I1a70d3f96b66b803f2d0ab14d00ed0df276ea500
Reviewed-on: https://go-review.googlesource.com/c/go/+/393365
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
---
src/cmd/link/internal/ld/deadcode.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go
index e4fa75f..21a9703 100644
--- a/src/cmd/link/internal/ld/deadcode.go
+++ b/src/cmd/link/internal/ld/deadcode.go
@@ -350,7 +350,7 @@ func deadcode(ctxt *Link) {
// in the last pass.
rem := d.markableMethods[:0]
for _, m := range d.markableMethods {
- if (d.reflectSeen && m.isExported()) || d.ifaceMethod[m.m] {
+ if (d.reflectSeen && (m.isExported() || d.dynlink)) || d.ifaceMethod[m.m] {
d.markMethod(m)
} else {
rem = append(rem, m)
--
1.8.3.1

View File

@ -66,7 +66,7 @@
Name: golang Name: golang
Version: 1.17.3 Version: 1.17.3
Release: 3 Release: 4
Summary: The Go Programming Language Summary: The Go Programming Language
License: BSD and Public Domain License: BSD and Public Domain
URL: https://golang.org/ URL: https://golang.org/
@ -156,6 +156,7 @@ Requires: openEuler-rpm-config
Patch6001: 0001-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch Patch6001: 0001-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch
Patch6002: 0002-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch Patch6002: 0002-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch
Patch6003: 0003-release-branch.go1.17-syscall-fix-ForkLock-spurious-.patch Patch6003: 0003-release-branch.go1.17-syscall-fix-ForkLock-spurious-.patch
Patch6004: 0004-backport-cmd-link-mark-unexported-methods-for-plugins.patch
ExclusiveArch: %{golang_arches} ExclusiveArch: %{golang_arches}
@ -390,6 +391,12 @@ fi
%files devel -f go-tests.list -f go-misc.list -f go-src.list %files devel -f go-tests.list -f go-misc.list -f go-src.list
%changelog %changelog
* Tue Jun 28 2022 Bin Hu <hubin73@huawei.com> - 1.17.3-4
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:backport patch to fix bug of golang plugin mode
* Fri May 6 2022 hanchao <hanchao47@huawei.com> - 1.17.3-3 * Fri May 6 2022 hanchao <hanchao47@huawei.com> - 1.17.3-3
- Type:CVE - Type:CVE
- CVE:CVE-2021-44717 - CVE:CVE-2021-44717