goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue44031/b")
        goCmd(t, "run", "-linkshared", "./issue44031/main")
 }
+
+// Test that we use a variable from shared libraries (which implement an
+// interface in shared libraries.). A weak reference is used in the itab
+// in main process. It can cause unreacheble panic. See issue 47873.
+func TestIssue47873(t *testing.T) {
+       goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue47837/a")
+       goCmd(t, "run", "-linkshared", "./issue47837/main")
+}
 
--- /dev/null
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package a
+
+type A interface {
+       M()
+}
+
+//go:noinline
+func TheFuncWithArgA(a A) {
+       a.M()
+}
+
+type ImplA struct{}
+
+//go:noinline
+func (A *ImplA) M() {}
 
--- /dev/null
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+       "testshared/issue47837/a"
+)
+
+func main() {
+       var vara a.ImplA
+       a.TheFuncWithArgA(&vara)
+}
 
                methods = methods[:0]
                for i := 0; i < relocs.Count(); i++ {
                        r := relocs.At(i)
-                       if r.Weak() {
+                       // When build with "-linkshared", we can't tell if the interface
+                       // method in itab will be used or not. Ignore the weak attribute.
+                       if r.Weak() && !(d.ctxt.linkShared && d.ldr.IsItab(symIdx)) {
                                continue
                        }
                        t := r.Type()