1
0
mirror of https://github.com/golang/go synced 2024-11-07 09:36:11 -07:00

[dev.link] cmd/internal/obj: sort ctxt.Data on AIX

On AIX, TOC symbols may be created and added to ctxt.Data
concurrently. To ensure reproducible builds, sort ctxt.Data.
This implements the same logic as WriteObjFile does for old
object files.

Change-Id: I2e6e2d7755352848981544a4fb68b828a188c2ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/201021
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2019-10-12 01:07:31 -04:00
parent d6535415fb
commit c9f633487b

View File

@ -37,6 +37,7 @@ import (
"fmt" "fmt"
"log" "log"
"math" "math"
"sort"
) )
func Linknew(arch *LinkArch) *Link { func Linknew(arch *LinkArch) *Link {
@ -167,6 +168,16 @@ func (ctxt *Link) NumberSyms(asm bool) {
return return
} }
if ctxt.Headtype == objabi.Haix {
// Data must be sorted to keep a constant order in TOC symbols.
// As they are created during Progedit, two symbols can be switched between
// two different compilations. Therefore, BuildID will be different.
// TODO: find a better place and optimize to only sort TOC symbols
sort.Slice(ctxt.Data, func(i, j int) bool {
return ctxt.Data[i].Name < ctxt.Data[j].Name
})
}
ctxt.pkgIdx = make(map[string]int32) ctxt.pkgIdx = make(map[string]int32)
ctxt.defs = []*LSym{} ctxt.defs = []*LSym{}
ctxt.nonpkgdefs = []*LSym{} ctxt.nonpkgdefs = []*LSym{}