]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link/internal/ld: fix external linking on windows
authorEgon Elbre <egonelbre@gmail.com>
Thu, 4 May 2017 13:14:59 +0000 (16:14 +0300)
committerAlex Brainman <alex.brainman@gmail.com>
Sat, 6 May 2017 06:11:31 +0000 (06:11 +0000)
gcc on windows writes invalid location for .debug_gdb_scripts
which causes the executable loading to fail.

Fixes #20183

Change-Id: I5134013bc926b44a55b528f66ab79555855d1f4d
Reviewed-on: https://go-review.googlesource.com/42651
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

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

index 205b39512e816c6d7bc36ee7330ff319043bf074..a0c5565cd2fae09b6485e5b1e1b87fb1088c91b8 100644 (file)
@@ -1448,6 +1448,11 @@ func writearanges(ctxt *Link, syms []*Symbol) []*Symbol {
 }
 
 func writegdbscript(ctxt *Link, syms []*Symbol) []*Symbol {
+       if Linkmode == LinkExternal && Headtype == objabi.Hwindows {
+               // gcc on Windows places .debug_gdb_scripts to a wrong location
+               // which causes program not to run. See https://golang.org/issue/20183
+               return syms
+       }
 
        if gdbscript != "" {
                s := ctxt.Syms.Lookup(".debug_gdb_scripts", 0)