]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: guarantee "section .debug_gdb_scripts" is always "$GOROOT/src/runtime/runti...
authorcrazycomputer <zhouguangyuan.xian@gmail.com>
Sun, 22 Aug 2021 09:26:20 +0000 (17:26 +0800)
committerThan McIntosh <thanm@google.com>
Tue, 24 Aug 2021 16:55:17 +0000 (16:55 +0000)
to guarantee the "section .debug_gdb_scripts" is  always "$GOROOT/src/runtime/runtime-gdb.py" , a check for package name is needed when search "runtime/proc.go".

Fixes #47881

Change-Id: Ib471314ca1a6777f625b488e5ae3790457540ef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/344229
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

src/cmd/link/internal/ld/dwarf.go

index c53d2408cbe5105fd9011b416e2d2d738241200d..98ab248e13f7034a9240ee900817aaf23e733491 100644 (file)
@@ -1190,7 +1190,7 @@ func (d *dwctxt) writeDirFileTables(unit *sym.CompilationUnit, lsu *loader.Symbo
                // We can't use something that may be dead-code
                // eliminated from a binary here. proc.go contains
                // main and the scheduler, so it's not going anywhere.
-               if i := strings.Index(name, "runtime/proc.go"); i >= 0 {
+               if i := strings.Index(name, "runtime/proc.go"); i >= 0 && unit.Lib.Pkg == "runtime" {
                        d.dwmu.Lock()
                        if gdbscript == "" {
                                k := strings.Index(name, "runtime/proc.go")