From: Cherry Zhang Date: Wed, 30 Oct 2019 23:49:53 +0000 (-0400) Subject: [dev.link] cmd/link: keep DWARF constant DIE symbols live X-Git-Tag: go1.14beta1~292^2^2~21 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5a210b58588f9614c33e1b1e7231a9968879d9e4;p=gostls13.git [dev.link] cmd/link: keep DWARF constant DIE symbols live DWARF constant DIE symbols are not referenced by any other symbol, but are needed by the DWARF pass, where they get linked to the compilation unit. Reenable gdb constant test. Change-Id: If77a0d379d9a6f1591939345bc31b027c2567f22 Reviewed-on: https://go-review.googlesource.com/c/go/+/204397 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Than McIntosh --- diff --git a/src/cmd/link/internal/ld/deadcode2.go b/src/cmd/link/internal/ld/deadcode2.go index 04a2e925c3..2517f7d159 100644 --- a/src/cmd/link/internal/ld/deadcode2.go +++ b/src/cmd/link/internal/ld/deadcode2.go @@ -6,6 +6,7 @@ package ld import ( "bytes" + "cmd/internal/dwarf" "cmd/internal/objabi" "cmd/internal/sys" "cmd/link/internal/loader" @@ -95,6 +96,14 @@ func (d *deadcodePass2) init() { names = append(names, exp) } + // DWARF constant DIE symbols are not referenced, but needed by + // the dwarf pass. + if !*FlagW { + for _, lib := range d.ctxt.Library { + names = append(names, dwarf.ConstInfoPrefix+lib.Pkg) + } + } + for _, name := range names { // Mark symbol as an data/ABI0 symbol. d.mark(d.ldr.Lookup(name, 0)) diff --git a/src/runtime/runtime-gdb_test.go b/src/runtime/runtime-gdb_test.go index c389b36efe..8cbc7638ca 100644 --- a/src/runtime/runtime-gdb_test.go +++ b/src/runtime/runtime-gdb_test.go @@ -489,8 +489,6 @@ func main() { ` func TestGdbConst(t *testing.T) { - t.Skip("TODO: newobj") // XXX the constant DIEs are not referenced, so they are not pulled in. Maybe it'll be fine if we rewrite linker's dwarf pass to index? - checkGdbEnvironment(t) t.Parallel() checkGdbVersion(t)