From: Joel Sing Date: Fri, 6 Sep 2019 18:40:38 +0000 (+1000) Subject: cmd/asm/internal/arch: consolidate LinkArch handling X-Git-Tag: go1.14beta1~1174 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=112a72a020f8976876ea7644f9220dbfb0f85464;p=gostls13.git cmd/asm/internal/arch: consolidate LinkArch handling Rather than manually setting the LinkArch for each case, pass the correct *obj.LinkArch to the arch* function, as is already done for archX86(). Change-Id: I4cf950780aa30a1385e785fb1d26edacb99bda79 Reviewed-on: https://go-review.googlesource.com/c/go/+/193818 Reviewed-by: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/asm/internal/arch/arch.go b/src/cmd/asm/internal/arch/arch.go index 221d80596a..638ab736cc 100644 --- a/src/cmd/asm/internal/arch/arch.go +++ b/src/cmd/asm/internal/arch/arch.go @@ -62,33 +62,19 @@ func Set(GOARCH string) *Arch { case "arm64": return archArm64() case "mips": - a := archMips() - a.LinkArch = &mips.Linkmips - return a + return archMips(&mips.Linkmips) case "mipsle": - a := archMips() - a.LinkArch = &mips.Linkmipsle - return a + return archMips(&mips.Linkmipsle) case "mips64": - a := archMips64() - a.LinkArch = &mips.Linkmips64 - return a + return archMips64(&mips.Linkmips64) case "mips64le": - a := archMips64() - a.LinkArch = &mips.Linkmips64le - return a + return archMips64(&mips.Linkmips64le) case "ppc64": - a := archPPC64() - a.LinkArch = &ppc64.Linkppc64 - return a + return archPPC64(&ppc64.Linkppc64) case "ppc64le": - a := archPPC64() - a.LinkArch = &ppc64.Linkppc64le - return a + return archPPC64(&ppc64.Linkppc64le) case "s390x": - a := archS390x() - a.LinkArch = &s390x.Links390x - return a + return archS390x() case "wasm": return archWasm() } @@ -352,7 +338,7 @@ func archArm64() *Arch { } -func archPPC64() *Arch { +func archPPC64(linkArch *obj.LinkArch) *Arch { register := make(map[string]int16) // Create maps for easy lookup of instruction names etc. // Note that there is no list of names as there is for x86. @@ -408,7 +394,7 @@ func archPPC64() *Arch { instructions["BL"] = ppc64.ABL return &Arch{ - LinkArch: &ppc64.Linkppc64, + LinkArch: linkArch, Instructions: instructions, Register: register, RegisterPrefix: registerPrefix, @@ -417,7 +403,7 @@ func archPPC64() *Arch { } } -func archMips() *Arch { +func archMips(linkArch *obj.LinkArch) *Arch { register := make(map[string]int16) // Create maps for easy lookup of instruction names etc. // Note that there is no list of names as there is for x86. @@ -464,7 +450,7 @@ func archMips() *Arch { instructions["JAL"] = mips.AJAL return &Arch{ - LinkArch: &mips.Linkmipsle, + LinkArch: linkArch, Instructions: instructions, Register: register, RegisterPrefix: registerPrefix, @@ -473,7 +459,7 @@ func archMips() *Arch { } } -func archMips64() *Arch { +func archMips64(linkArch *obj.LinkArch) *Arch { register := make(map[string]int16) // Create maps for easy lookup of instruction names etc. // Note that there is no list of names as there is for x86. @@ -521,7 +507,7 @@ func archMips64() *Arch { instructions["JAL"] = mips.AJAL return &Arch{ - LinkArch: &mips.Linkmips64, + LinkArch: linkArch, Instructions: instructions, Register: register, RegisterPrefix: registerPrefix,