]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: restore export data hash
authorCherry Zhang <cherryyz@google.com>
Thu, 17 Oct 2019 05:17:42 +0000 (01:17 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 17 Oct 2019 20:28:28 +0000 (20:28 +0000)
With the previous CL, the export data will not change whether it
is compiled with -dynlink flag or not. Restore the export data
hash, and reenable plugin version check.

TODO: it may be still better to just generate a fingerprint for
each package at compile time.

Change-Id: I1f298ac97c3ab9b8d05d1c95e8be74d10ca7cd0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/201720
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
misc/cgo/testplugin/testdata/host/host.go
src/cmd/link/internal/ld/lib.go

index d836523da875c6b728898554efb95f1d72168b4f..a3799328cdc2b81f4ca1eea6670df6bf27e46896 100644 (file)
@@ -145,13 +145,12 @@ func main() {
        }
 
        _, err = plugin.Open("plugin-mismatch.so")
-       // TODO: newobj
-       //if err == nil {
-       //      log.Fatal(`plugin.Open("plugin-mismatch.so"): should have failed`)
-       //}
-       //if s := err.Error(); !strings.Contains(s, "different version") {
-       //      log.Fatalf(`plugin.Open("plugin-mismatch.so"): error does not mention "different version": %v`, s)
-       //}
+       if err == nil {
+               log.Fatal(`plugin.Open("plugin-mismatch.so"): should have failed`)
+       }
+       if s := err.Error(); !strings.Contains(s, "different version") {
+               log.Fatalf(`plugin.Open("plugin-mismatch.so"): error does not mention "different version": %v`, s)
+       }
 
        _, err = plugin.Open("plugin2-dup.so")
        if err == nil {
index 063bdded0ce0112b2987321283e0f45b44af2cb3..63dcb22d9874b54a9073276f82fa78fec9894221 100644 (file)
@@ -816,7 +816,7 @@ func genhash(ctxt *Link, lib *sym.Library) {
                return
        }
        h.Write(pkgDefBytes[0:firstEOL])
-       //h.Write(pkgDefBytes[firstDoubleDollar : firstDoubleDollar+secondDoubleDollar]) // TODO: newobj: -dynlink may change symbol numbering? which will make the export data differ
+       h.Write(pkgDefBytes[firstDoubleDollar : firstDoubleDollar+secondDoubleDollar])
        lib.Hash = hex.EncodeToString(h.Sum(nil))
 }