]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: always disable lazy PLT resolution when dynamically linking Go
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Thu, 15 Oct 2015 08:48:11 +0000 (21:48 +1300)
committerMichael Hudson-Doyle <michael.hudson@canonical.com>
Sat, 17 Oct 2015 01:01:42 +0000 (01:01 +0000)
Go cannot allow lazy PLT resolution when calling between Go functions because
the lazy resolution can use more stack than is available. Lazy resolution is
disabled by passing -z now to the system linker, but unfortunately was only
passed when linking to a Go shared library. That sounds fine, but the shared
library containing the runtime is not linked to any other Go shared library but
calls main.init and main.main via a PLT, and before this fix this did use lazy
resolution. (For some reason this never caused a problem on intel, but it
breaks on ppc64le). Fortunately the fix is very simple: always pass -z now to
the system linker when dynamically linking Go.

Change-Id: I7806d40aac80dcd1e56b95864d1cfeb1c42614e2
Reviewed-on: https://go-review.googlesource.com/15870
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/link/internal/ld/lib.go

index 3ce22017cfe1e5194e1545f555615f8fbf792490..8784e9d38f14e263eadd77f210a69d84d4e63ed9 100644 (file)
@@ -1006,7 +1006,7 @@ func hostlink() {
                argv = append(argv, "-shared")
        }
 
-       if Linkshared && Iself {
+       if Iself && DynlinkingGo() {
                // We force all symbol resolution to be done at program startup
                // because lazy PLT resolution can use large amounts of stack at
                // times we cannot allow it to do so.