]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/link: don't decode type symbol in shared library in deadcode
authorCherry Zhang <cherryyz@google.com>
Mon, 1 Feb 2021 18:36:50 +0000 (13:36 -0500)
committerCherry Zhang <cherryyz@google.com>
Tue, 2 Feb 2021 16:00:58 +0000 (16:00 +0000)
commit98f8454a73b569d81d1c5e167d7b68f22e2e3fea
tree30baeb9e90cbad80f4bf04b17843305227803603
parent1426a571b79bfcb3c0339e2fd96c893cd1549af6
cmd/link: don't decode type symbol in shared library in deadcode

In the linker's deadcode pass we decode type symbols for
interface satisfaction analysis. When linking against Go shared
libraries, the type symbol may come from a shared library, so it
doesn't have data in the current module being linked, so we cannot
decode it. We already have code to skip DYNIMPORT symbols. However,
this doesn't actually work, because at that point the type symbols'
names haven't been mangled, whereas they may be mangled in the
shared library. So the symbol definition (in shared library) and
reference (in current module) haven't been connected.

Skip decoding type symbols of type Sxxx (along with DYNIMPORT)
when linkShared.

Note: we cannot skip all type symbols, as we still need to mark
unexported methods defined in the current module.

Fixes #44031.

Change-Id: I833d19a060c94edbd6fc448172358f9a7d760657
Reviewed-on: https://go-review.googlesource.com/c/go/+/288496
Trust: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
misc/cgo/testshared/shared_test.go
misc/cgo/testshared/testdata/issue44031/a/a.go [new file with mode: 0644]
misc/cgo/testshared/testdata/issue44031/b/b.go [new file with mode: 0644]
misc/cgo/testshared/testdata/issue44031/main/main.go [new file with mode: 0644]
src/cmd/link/internal/ld/deadcode.go