]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: keep DWARF constant DIE symbols live
authorCherry Zhang <cherryyz@google.com>
Wed, 30 Oct 2019 23:49:53 +0000 (19:49 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 31 Oct 2019 01:09:58 +0000 (01:09 +0000)
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 <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/deadcode2.go
src/runtime/runtime-gdb_test.go

index 04a2e925c31b961e6f60b67f26c30978fd77579b..2517f7d1599aea987c45a9351348e95e3d3fc408 100644 (file)
@@ -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))
index c389b36efe4ecad8e395a10bb18c58f2d5a82932..8cbc7638ca7c89319082909afaf55b4088e843a1 100644 (file)
@@ -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)