cmd/link: do not close over the loop variable in testDWARF

Fixes #30429
Updates #16520
Updates #20733

Change-Id: Iae41f06c09aaaed500936f5496d90cefbe8293e4
Reviewed-on: https://go-review.googlesource.com/c/164119
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/src/cmd/link/dwarf_test.go b/src/cmd/link/dwarf_test.go
index 710457a..880b2ce 100644
--- a/src/cmd/link/dwarf_test.go
+++ b/src/cmd/link/dwarf_test.go
@@ -44,6 +44,7 @@
 	defer os.RemoveAll(tmpDir)
 
 	for _, prog := range []string{"testprog", "testprogcgo"} {
+		prog := prog
 		t.Run(prog, func(t *testing.T) {
 			t.Parallel()