aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/ld/deadcode.go
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2024-05-24 18:04:11 -0400
committerCherry Mui <cherryyz@google.com>2024-06-07 14:52:41 +0000
commit98529a8e7cf1cc0b561f26a4bd3ddf8f6dbd2f8a (patch)
tree55602989c8923e4d9407aa7e78f6e714dd60dd9c /src/cmd/link/internal/ld/deadcode.go
parentf7c330eac7777612574d8a1652fd415391f6095e (diff)
downloadgo-98529a8e7cf1cc0b561f26a4bd3ddf8f6dbd2f8a.tar.xz
cmd/link: don't include deadcoded function symbols in shared build mode
In shared build mode, we include all symbols. This includes function symbols that are deadcoded by the compiler. They don't really get compiled, and their metadata may be missing, causing linker failures. Skip them. Fixes #67635. Change-Id: Ic0e64bd032be499cca26da5e9e3ffbe9998bac05 Reviewed-on: https://go-review.googlesource.com/c/go/+/588316 Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/link/internal/ld/deadcode.go')
-rw-r--r--src/cmd/link/internal/ld/deadcode.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go
index 241cf603db..20609ed7bf 100644
--- a/src/cmd/link/internal/ld/deadcode.go
+++ b/src/cmd/link/internal/ld/deadcode.go
@@ -50,6 +50,12 @@ func (d *deadcodePass) init() {
n := d.ldr.NDef()
for i := 1; i < n; i++ {
s := loader.Sym(i)
+ if d.ldr.SymType(s) == sym.STEXT && d.ldr.SymSize(s) == 0 {
+ // Zero-sized text symbol is a function deadcoded by the
+ // compiler. It doesn't really get compiled, and its
+ // metadata may be missing.
+ continue
+ }
d.mark(s, 0)
}
d.mark(d.ctxt.mainInittasks, 0)