]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go, cmd/link, cmd/dist: re-enable plugin mode on darwin/amd64
authorHiroshi Ioka <hirochachacha@gmail.com>
Mon, 4 Sep 2017 12:23:29 +0000 (21:23 +0900)
committerDavid Crawshaw <crawshaw@golang.org>
Sun, 10 Sep 2017 12:54:13 +0000 (12:54 +0000)
1. remove broken verification
   The runtime check assumes that no-pcln symbol entry have zero value,
   but the linker emit no entries if the symbol is no-pcln.
   As a result, if there are no-pcln symbols at the very end of pcln
   table, it will panic.
2. correct condition of export
   Handle special chracters in pluginpath correcty.
   Export "go.itab.*", so different plugins can share the same itab.

Fixes #18190

Change-Id: Ia4f9c51d83ce8488a9470520f1ee9432802cfc1d
Reviewed-on: https://go-review.googlesource.com/61091
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

misc/cgo/testplugin/test.bash
src/cmd/dist/test.go
src/cmd/go/internal/work/build.go
src/cmd/link/internal/ld/macho.go
src/runtime/symtab.go

index f64be9b0ffe3e9bda7a6091bedfa88bed61b93f9..b532676eb677f83e00e2443e53176947e5a61e49 100755 (executable)
@@ -40,11 +40,21 @@ GOPATH=$(pwd) go build -buildmode=plugin iface_b
 GOPATH=$(pwd) go build iface
 LD_LIBRARY_PATH=$(pwd) ./iface
 
+function _timeout() (
+       set -e
+       $2 &
+       p=$!
+       (sleep $1; kill $p 2>/dev/null) &
+       p2=$!
+       wait $p 2>/dev/null
+       kill -0 $p2 2>/dev/null
+)
+
 # Test for issue 18676 - make sure we don't add the same itab twice.
 # The buggy code hangs forever, so use a timeout to check for that.
 GOPATH=$(pwd) go build -buildmode=plugin -o plugin.so src/issue18676/plugin.go
 GOPATH=$(pwd) go build -o issue18676 src/issue18676/main.go
-timeout 10s ./issue18676
+_timeout 10 ./issue18676
 
 # Test for issue 19534 - that we can load a plugin built in a path with non-alpha
 # characters
index 89014e5d0a9b556795e00f63c71c0e7c20832c5f..b9766019be2fc11d3c8a195e89f9747b9815ceaa 100644 (file)
@@ -850,6 +850,8 @@ func (t *tester) supportedBuildmode(mode string) bool {
                switch pair {
                case "linux-386", "linux-amd64", "linux-arm", "linux-s390x":
                        return true
+               case "darwin-amd64":
+                       return true
                }
                return false
        default:
index d2e2253512d6d11387fc3d813a6271885f279d6b..e9c94015eaf7b94f7f4afcc367c5446d6d52d72b 100644 (file)
@@ -358,6 +358,9 @@ func BuildModeInit() {
                        switch platform {
                        case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x",
                                "android/amd64", "android/arm", "android/arm64", "android/386":
+                       case "darwin/amd64":
+                               // Skip DWARF generation due to #21647
+                               cfg.BuildLdflags = append(cfg.BuildLdflags, "-w")
                        default:
                                base.Fatalf("-buildmode=plugin not supported on %s\n", platform)
                        }
index 10d50d52249d6a4e8fa0002aea6ae3213c3d01e5..0d9b8246386fee1460c053b930c5dd7394b8e67e 100644 (file)
@@ -5,6 +5,7 @@
 package ld
 
 import (
+       "cmd/internal/objabi"
        "cmd/internal/sys"
        "sort"
        "strings"
@@ -746,7 +747,10 @@ func machoShouldExport(ctxt *Link, s *Symbol) bool {
        if !ctxt.DynlinkingGo() || s.Attr.Local() {
                return false
        }
-       if Buildmode == BuildmodePlugin && strings.HasPrefix(s.Extname, *flagPluginPath) {
+       if Buildmode == BuildmodePlugin && strings.HasPrefix(s.Extname, objabi.PathToPrefix(*flagPluginPath)) {
+               return true
+       }
+       if strings.HasPrefix(s.Name, "go.itab.") {
                return true
        }
        if strings.HasPrefix(s.Name, "type.") && !strings.HasPrefix(s.Name, "type..") {
index 4a68f4eaa0ca481d5911b8af923c388a8f95ee49..7e001c96b1ce6ad5788039ee0f0abd4d574884d7 100644 (file)
@@ -526,7 +526,6 @@ func moduledataverify1(datap *moduledata) {
 
        // ftab is lookup table for function by program counter.
        nftab := len(datap.ftab) - 1
-       var pcCache pcvalueCache
        for i := 0; i < nftab; i++ {
                // NOTE: ftab[nftab].entry is legal; it is the address beyond the final function.
                if datap.ftab[i].entry > datap.ftab[i+1].entry {
@@ -542,30 +541,6 @@ func moduledataverify1(datap *moduledata) {
                        }
                        throw("invalid runtime symbol table")
                }
-
-               if debugPcln || nftab-i < 5 {
-                       // Check a PC near but not at the very end.
-                       // The very end might be just padding that is not covered by the tables.
-                       // No architecture rounds function entries to more than 16 bytes,
-                       // but if one came along we'd need to subtract more here.
-                       // But don't use the next PC if it corresponds to a foreign object chunk
-                       // (no pcln table, f2.pcln == 0). That chunk might have an alignment
-                       // more than 16 bytes.
-                       f := funcInfo{(*_func)(unsafe.Pointer(&datap.pclntable[datap.ftab[i].funcoff])), datap}
-                       end := f.entry
-                       if i+1 < nftab {
-                               f2 := funcInfo{(*_func)(unsafe.Pointer(&datap.pclntable[datap.ftab[i+1].funcoff])), datap}
-                               if f2.pcln != 0 {
-                                       end = f2.entry - 16
-                                       if end < f.entry {
-                                               end = f.entry
-                                       }
-                               }
-                       }
-                       pcvalue(f, f.pcfile, end, &pcCache, true)
-                       pcvalue(f, f.pcln, end, &pcCache, true)
-                       pcvalue(f, f.pcsp, end, &pcCache, true)
-               }
        }
 
        if datap.minpc != datap.ftab[0].entry ||