]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: ensure deterministic order in dynexp
authorCherry Zhang <cherryyz@google.com>
Wed, 30 Oct 2019 22:07:55 +0000 (18:07 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 31 Oct 2019 01:09:34 +0000 (01:09 +0000)
dynexp is used for generating the dynamic symbol table. It is
created from a map. Sort it to ensure deterministic order.

Should fix solaris build.

Change-Id: I561b9da3a4136a7ea41139073f76c98fb069d4fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/204378
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/util.go

index 4017ea1c79c478cb131f7de7eb5129eae5abe3f0..1cbfc10ab05aedb1e340f1509682a276f0a708c2 100644 (file)
@@ -58,6 +58,7 @@ import (
        "os/exec"
        "path/filepath"
        "runtime"
+       "sort"
        "strings"
        "sync"
 )
@@ -540,6 +541,7 @@ func setupdynexp(ctxt *Link) {
                s := ctxt.Syms.Lookup(exp, 0)
                dynexp = append(dynexp, s)
        }
+       sort.Sort(byName(dynexp))
 
        // Resolve ABI aliases in the list of cgo-exported functions.
        // This is necessary because we load the ABI0 symbol for all
index b5b02296a14d2750b51affb6e779dbc3ed7d36b1..488386fec213591389633d66e37b05d6e40305d9 100644 (file)
@@ -99,3 +99,10 @@ func contains(s []string, v string) bool {
        }
        return false
 }
+
+// implements sort.Interface, for sorting symbols by name.
+type byName []*sym.Symbol
+
+func (s byName) Len() int           { return len(s) }
+func (s byName) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
+func (s byName) Less(i, j int) bool { return s[i].Name < s[j].Name }